core-animation

Is there an issue with updating a CALayer position while the layer is paused?

青春壹個敷衍的年華 提交于 2019-12-03 14:51:23
Is there an issue with reading the presentation position while it's paused? I'm trying to pause and resume a CALayer . Once the CALayer is paused, I want to update the layer's position with it's current presentation position. When I try do this, the layer flickers slightly once I resume the layer. This is the code I'm using to pause and resume the CALayer (based on a Technical Q&A QA1673 supplied by Apple): CFTimeInterval pausedTime; void pauseLayer(CALayer *layer) { pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil]; layer.speed = 0.0; layer.timeOffset = pausedTime; layer

Interpolating values between interval, interpolation as per Bezier curve

丶灬走出姿态 提交于 2019-12-03 14:48:42
问题 To implement a 2D animation I am looking for interpolating values between two key frames with the velocity of change defined by a Bezier curve. The problem is Bezier curve is represented in parametric form whereas requirement is to be able to evaluate the value for a particular time. To elaborate, lets say the value of 10 and 40 is to be interpolated across 4 seconds with the value changing not constantly but as defined by a bezier curve represented as 0,0 0.2,0.3 0.5,0.5 1,1. Now if I am

How can I restart my block-based animation when the application comes to the foreground?

霸气de小男生 提交于 2019-12-03 14:46:27
I have the following block-based animation: [UIView animateWithDuration:0.5f delay:0.0f options:UIViewAnimationOptionRepeat|UIViewAnimationOptionAutoreverse|UIViewAnimationOptionAllowUserInteraction|UIViewAnimationOptionCurveEaseInOut animations:^{ [view.layer setTransform:CATransform3DMakeScale(1.3f, 1.3f, 1.0f)]; NSLog(@"animating"); }completion:^(BOOL finished){ NSLog(@"Completed"); }]; When the app returns from being in the background, the completion block is called, and my animations don't restart. I've tried to use the following delegate method to restart the animations: - (void

Can CARemoteLayerServer and CARemoteLayerClient be used between processes?

为君一笑 提交于 2019-12-03 14:24:01
In Mac OS X Lion CARemoteLayerServer and CARemoteLayerClient were added to QuartzCore. I've been trying to investigate if they'd be suitable for splitting a graphical application between multiple processes, but without success. I can use them successfully within a single process, with some code along the lines of this: - (void)buildLayerSingleProcess { CARemoteLayerServer *server = [CARemoteLayerServer sharedServer]; self.client = [[CARemoteLayerClient alloc] initWithServerPort: server.serverPort]; uint32_t clientID = self.client.clientId; CALayer *layer1 = [CALayer layer]; layer1.bounds =

What are Layers good for? What could I do with adding an Layer, and why should I think about Layers?

懵懂的女人 提交于 2019-12-03 14:02:44
问题 I am wondering what makes Layers different from Views, when every View comes along with it's own Layer. Maybe I am wrong with that. But then: What are these Layers good for? Like I understand it, I would use an UIView to group elements in my GUI. I could also use that UIView to position things over other things. So where come Layers into place here? Should I think of them just as the z-index like in HTML / CSS? Are they just interesting for Core Animation stuff? 回答1: Compared to UIVIews,

Changing cornerRadius using Core Animation

孤街浪徒 提交于 2019-12-03 13:55:38
I am trying to change the corner radius of a button (OpenNoteVisible.layer) in the following way: CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"cornerRadius"]; animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; animation.fromValue = [NSNumber numberWithFloat:10.0f]; animation.toValue = [NSNumber numberWithFloat:0.0f]; animation.duration = 1.0; [animation.layer setCornerRadius:140.0]; [OpenNoteVisible.layer addAnimation:animation forKey:@"cornerRadius"]; But this code gives an error at the line [animation.layer

How do I create a custom page curl Core Animation?

一曲冷凌霜 提交于 2019-12-03 13:29:21
问题 I'm trying to create a "page curl" animation of an image in my iPhone application. I t UIViewAnimationTransitionCurlUp, and it's undocumented Core Animation siblings, however the image I need to animate is a transparent PNG, with "uneven" (some alpha pixels) outlines. When using the aforementioned pre-made transition, those alpha pixels are painted black as soon as the animation starts, which looks terribly ugly. Therefore, I seek to create a Core Animation of my own. I have tried to research

How to inherit animation properties while animating CALayer with implicit animation

此生再无相见时 提交于 2019-12-03 13:28:53
I am trying to animate a custom property on a CALayer with an implicit animation: [UIView animateWithDuration:2.0f animations:^{ self.imageView.myLayer.myProperty = 1; }]; In -actionForKey: method I need to return the animation taking care of interpolating the values. Of course I have to tell somehow the animation how to retrieve the other parameters for the animation (i.e. the duration and the timing function ). - (id<CAAction>)actionForKey:(NSString *)event { if ([event isEqualToString:@"myProperty"]) { CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"myProperty"]; [anim

Force clockwise/anticlockwise rotation for a CABasicAnimation of a UIImageView

回眸只為那壹抹淺笑 提交于 2019-12-03 13:10:06
I'm animating a pendulum which swings from 0 degrees to max 200 degrees and then back again. The problem is that if the pendulum goes over 180 degrees, it returns to 0 by the shortest route which is to continue clockwise. And I'd like it to go anticlockwise. Here's my code: ('right' is a boolean which is TRUE when the pendulum is swinging from left to right) - (void)swingPendulum { CABasicAnimation *rotationAnimation; rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; if (right) rotationAnimation.toValue = [NSNumber numberWithFloat:degreesToRadians(kMax)];

Is it possible to play a path backwards in a CAKeyFrameAnimation?

久未见 提交于 2019-12-03 11:29:45
问题 I want to animate the position of a CALayer based on a CGPath, but I want to play it backwards. Is there any way to animate a path backwards, or reverse a CGPath? 回答1: animation.speed = -1; ? 回答2: This may not be the best solution, but it worked for me. I told the animation to autoreverse, then started it halfway in. But to prevent it from animating back again I needed to terminate it early. - (void) animate { CAKeyframeAnimation * pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@