iOS graphics and animation

CAAnimation hierarchy

  1. CAPropertyAnimation CAAnimation is a subclass is an abstract class, in order to create animated objects, should use its two subclasses: CABasicAnimation and CAKeyframeAnimation
    property parsing:
    keyPath: attribute name by specifying a CALayer for keyPath (NSString type), and on CALayer attribute value modification, to achieve the corresponding animation. For example, specify @ "position" as keyPat value of the property, change the value of the position property of CALayer to achieve the panning animation.

CABasicAnimation, CAPropertyAnimation subclass
attributes Analytical:
fromValue: Initial value of the corresponding attribute keyPath
toValue: End value of the corresponding attribute keyPath
as animation, the length of the duration of the duration, the value of the corresponding attribute keyPath gradually changed from fromValue as toValue. If fillMode = kCAFillModeForwards and removedOnCompletion = NO, then after the animation is finished, the layer will retain the status display animation execution. But in essence, the layer of the property value or the initial value of the animation before execution, and not really be changed. For example: CALayer initial value of the position (0,0), CABasicAnimation of fromValue is (10,10), toValue is (100, 100), although the animation is finished after the layer is maintained at (100, 100) in this position, in essence, the position on the layer or for the (0,0).

CAKeyframeAnimation, CAPropertyAnimation subclass, with the difference that CABasicAnimation: CABasicAnimation only change from one value (fromValue) to another value (toValue), and uses a NSArray CAKeyframeAnimation save these values
properties resolved:
values: that is, the above-described objects NSArray . Inside the element called "key frames" (keyframe). The animation objects within the specified time (duration), sequentially displaying each keyframe values array.
path: You can set a CGPathRef \ CGMutablePathRef, so that layer moving along the path. path only work for the CALayer anchorPoint and position. If you set the path, then the values will be ignored.
keyTimes: a frame may be designated as a key corresponding to the corresponding point in time, which is in the range from 0 to 1.0, each time value corresponds keytimes the values in each frame, when keytimes not set, each key frame time is halved.
CABasicAnimation can be seen as only a maximum of two key frames CAKeyframeAnimation

CAAnimationGroup, CAAnimation subclass, can save a set of animation objects, the back layer is added, all the group objects can be concurrent animations run CAAnimationGroup object.

Properties resolve:
Animations: to save a set of animated objects NSArray
case, a group of animated objects is run by default, it can be pleasant to change the start time of the animation by animating objects beginTime

CATransition, CAAnimation subclasses, used to make transition animations, can be provided into and out of the screen to animate the screen layer. iOS than the transition animation effects a little less macOS X

UINavigationController is achieved by CATransition the view controller push screen animation
attributes resolve:
of the type: Excessive animation type
subType: animated transitions direction
startProgress: the starting point of the animation (animation in the overall percentage of)
endProgress: Animation end the whole animation (in the percentage)

UIView animation

UIKit animation directly integrated into the UIView class, when some of the attributes of internal changes occur, these changes will provide UIView animation support
implementation of the required animation work is done automatically by the UIView class, but still want to notice in view of the implementation of animation, the need to change the code for this attribute in [UIView beginAnimations: nil context: nil ] and [UIView commitAnimations] between

Block animation
frame animation

Guess you like

Origin blog.csdn.net/weixin_33937913/article/details/90852757