Practice it before writing it!
I have never been familiar with Ca, and it is still quite difficult for me.
The transition time is a little long.
In the middle, there are other tasks with higher priority than the HUD I want to do. So I 've been dragging it on until now.
It took me two days to learn about ca animation, find code on the Internet, and paste code. Then I learned how to use it ......
It's done.
This process has benefited a lot! Not only have I learned
Calayer
Cabasicanimation
Also try to customize a layer and then operate the layer to complete the animation.
The results are good.
Paste some code to the animation functions for the effects such as layer rotation and opacity!
// Back to the essential question: How can I draw an automatically rotated circle with an edge gradient color!
This function can help you solve the problem. Use a gradient color circle as your layer chart. That is, the image you want to rotate. Then you can call this function and turn it...
This is really the simplest and most practical method I have found.
//rotation animation- (void) runSpinAnimationOnView:(CALayer*)layerToAnimate duration:(CGFloat)duration rotations:(CGFloat)rotations repeat:(float)repeat;{ CABasicAnimation* rotationAnimation; rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 /* full rotation*/ * rotations * duration ]; rotationAnimation.duration = duration; rotationAnimation.cumulative = YES; rotationAnimation.repeatCount = repeat; [layerToAnimate addAnimation:rotationAnimation forKey:@"rotationAnimation"];}
// Your layer can be a graph and then flash by adjusting the transparency (of course there must be another way) // Flash animation-(void) opacityforever_animation :( float) time withlayer :( calayer *) layer {cabasicanimation * animation = [cabasicanimation animationwithkeypath: @ "opacity"]; animation. fromvalue = [nsnumber numberwithfloat: 1.0]; animation. tovalue = [nsnumber numberwithfloat: 0.5]; animation. autoreverses = yes; animation. duration = time; animation. repeatcount = flt_max; animation. removedoncompletion = no; animation. fillmode = kcafillmodeforwards; [layer addanimation: animation forkey: @ "opacity"];}-(void) moveduration :( float) Time fromoffset :( float) fromvalue withoffsetx :( float) X withlayer :( calayer *) layer {cabasicanimation * animation = [cabasicanimation animationwithkeypath: @ "transform. translation. X "]; animation. fromvalue = [nsnumber numberwithfloat: fromvalue]; animation. tovalue = [nsnumber numberwithfloat: X]; animation. duration = time; animation. removedoncompletion = no; animation. fillmode = kcafillmodeforwards; [layer addanimation: animation forkey: @ "transform. translation. X "];}