core-animation

Is CABasicAnimation's toValue relative to initial position?

冷暖自知 提交于 2019-12-11 13:31:18
问题 I have a CALayer that I'm explicitly animating to a new position. My toValue property seems only relative to the layer's initial position. CABasicAnimation *move = [CABasicAnimation animationWithKeyPath:@"position"]; move.fromValue = [NSValue valueWithCGPoint:CGPointMake(blueDot.position.x, blueDot.position.y)]; move.toValue = [NSValue valueWithCGPoint:CGPointMake(self.view.center.x, self.view.center.y)]; move.duration = 1.0; [blueDot addAnimation:move forKey:@"myMoveAnimation"]; blueDot

Drastic slowdown using layer backed NSOpenGLView

一笑奈何 提交于 2019-12-11 12:59:14
问题 I needed to display some Cocoa widgets on top of an NSOpenGLView in an existing app. I followed the example in Apple's LayerBackedOpenGLView example code. The NSOpenGLView is given a backing layer using: [glView setWantsLayer:YES] Then the Cocoa NSView with the widgets is added as a subview of the glView . This is basically working and is twice ad fast as my previous approach where I added the NSView containing the widgets to a child window of the window containing the glView (this was the

Flickering in CABasicAnimation for rotation

懵懂的女人 提交于 2019-12-11 12:51:46
问题 I am trying to rotate a CAShapeLayer by an angle from its current angle whenever a button is pressed. I am using delegate function animationDidStop to set the transform of the layer during end of animation, since I have noticed animation only changes the transform of the presentation layer and not the layer in itself. But there are random flickering in the animation which seems to be during the end of the animation when the animation is complete due to layer going back to its previous

Animate the change of a stroke color on UIView

时光怂恿深爱的人放手 提交于 2019-12-11 12:23:18
问题 I'd like to "pulse" the stroke color on a path that I've drawn in a UIView's drawRect. But not sure this is possible? - (void)highlightView { if (!isHighlighted) { [UIView beginAnimations:NULL context:nil]; [UIView setAnimationDuration:0.75]; self.strokeColor = kHighlightColor; self.strokeWidth = 2.0; [UIView commitAnimations]; self.isHighlighted = YES; } } I'm only able to see the change if i setNeedsDisplay on the view. But that bypasses the animation. I can think of a few workarounds if

How can I detect a touch on an animated subview ? Or click an animated UIButton?

风流意气都作罢 提交于 2019-12-11 11:08:00
问题 I have a view that is moving. The view is sometimes on and sometimes off screen - it is twice the width of the screen. In this view, there are buttons that I need to be able to click. I've tried doing this in many ways already - using pure buttons using touches began on UIView I'm doing the animation using a CGPath in core animation Any help would be most appreciated Thanks 回答1: Whether the view is moving or not should irrelevent to the touch detection. If you have a UIButton object and are

Swift: How to enable pinch-to-zoom for CALayer?

半城伤御伤魂 提交于 2019-12-11 11:03:31
问题 I have been trying to scroll and zoom a CALayer, specifically a CAShapeLayer, of several polygon paths. I added the CALayer to a UIScrollView which has successfully enabled scrolling around the CALayer. However, pinch to zoom is not working. Several tutorials have implemented zooming a UIImageView with the UIScrollViewDelegate essentially like so: @IBOutlet var scrollView : UIScrollView! var imageView = UIImageView() scrollView.addSubview(imageView) func viewForZoomingInScrollView(scrollView:

CATransaction complete block success or failure

纵饮孤独 提交于 2019-12-11 11:00:27
问题 I am working with Core Animation using CATransaction . I am using setCompletionBlock in order to capture when the animation is complete so that I can do stuff with the data in the view controller, but I want the animation to be interruptible. Eg. when I call [self.layer removeAllAnimations] the animation should stop but the setCompletionBlock should also KNOW if the animation succeeded or failed. With UIView animation, this is possible since there is a finished variable passed in the

CABasicAnimation resets when edge swiping with UINavigationController

徘徊边缘 提交于 2019-12-11 10:11:25
问题 I have the following CABasicAnimation run in my viewDidLoad for a view controller inside a UINavigationController : CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; animation.duration = 1; animation.additive = NO; animation.removedOnCompletion = NO; animation.fillMode = kCAFillModeForwards; animation.fromValue = [NSNumber numberWithFloat:0]; animation.toValue = [NSNumber numberWithFloat:-1*(((-windBearing+180) * M_PI) / 180)]; [compass.layer

Change CALayer properties: EXC_BAD_INSTRUCTION

青春壹個敷衍的年華 提交于 2019-12-11 10:10:37
问题 I'm trying to implement selection of a subLayer by clicking on it and visualize that it is had been selected by for example changing the background color of the subLayer. However, I end up with the following error whatever and however I attempt to change any property: Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) Her is my function that is called from my NSView sub class' mouseUp function. func SelectObject( atPoint: NSPoint) { let thePoint = atPoint as CGPoint if let

Where am I leaking CGMutablePathRef in this code?

守給你的承諾、 提交于 2019-12-11 09:18:46
问题 In my code I have CGMutablePathRef thePath = CGPathCreateMutable(); If I don't release it I literally get thousands of leaks because I'm doing the action constantly. However, if I do release it, my game eventually crashes. Any ideas? Is it possible I'm releasing it in the wrong place? -(void)MoveObject:(int)Tag { representationX = gameViewObj.spaceshipImageView.center.x; representationY = gameViewObj.spaceshipImageView.center.y; CALayer *spaceshipLayer = gameViewObj.spaceshipImageView.layer;