Directory of this document
- First, Core animation introduction
- Second, the use of Core animation steps
- Third, caanimation
- Iv. capropertyanimation
Back to top one, Core animation introduction
* Core Animation, the Chinese translation is a central animation, it is a very powerful set of animation processing API, using it can make a very beautiful animation effect, and often do more with less. In other words, very powerful functionality can be achieved with a small amount of code.
* Core animation can be used on Mac OS X and iOS platforms.
* Amid the power of core animation at the WWDC conference in 2007: Click to view video
* Core animation animations are performed in the background and do not block the main thread.
* It is important to note that Core animation is directly acting on calayer, not uiview.
Back to top second, Core animation use steps
1. Use it to first add the Quartzcore.framework framework and introduce the main header file <QuartzCore/QuartzCore.h>
2. Initialize a Caanimation object and set some animation-related properties
3. Add the Caanimation object to Calayer by calling Calayer's Addanimation:forkey: method to start the animation
4. You can stop the animation in Calayer by calling Calayer's Removeanimationforkey: Method
Back to the top three, caanimation
* As you can see from the previous narrative, to perform an animation, you must initialize a Caanimation object.
* In fact, in general, we use more of the caanimation subclass, so we'll take a look at the inheritance structure of caanimation:
The black line represents the inheritance, the dark text represents the class name, and the white text represents the attribute. Where Camediatiming is a protocol (protocol).
Common Properties of 1.CAAnimation
* Caanimation is the parent class of all animation classes, but it cannot be used directly and should use its subclasses
* Common properties are:
1> Duration: Duration of animation
2> repeatcount: Number of repetitions of an animation
3> timingfunction: Controlling the rhythm of animation operation
Timingfunction the optional values are:
- Kcamediatimingfunctionlinear (linear): constant speed, gives you a relatively static feeling
- Kcamediatimingfunctioneasein (Progressive): Animation slowly enters, then accelerates to leave
- Kcamediatimingfunctioneaseout (Fade Out): Animation enters at full speed, then slows down to the destination
- Kcamediatimingfunctioneaseineaseout (gradual fade Out): The animation slowly enters, the middle accelerates, then slows down to reach the destination. This is the default animation behavior.
4> Delegate: Animation agent for monitoring the execution of animations
The proxy object needs to be implemented in the following ways: (These methods are defined in a category)
1 @interface nsobject (caanimationdelegate) 2//trigger This method when the animation starts execution 3-(void) Animationdidstart: (Caanimation *) anim;4 5//Animation This method is triggered when the line is complete 6-(void) Animationdidstop: (Caanimation *) Anim finished: (BOOL) flag;7 @end
* All of the properties described above are caanimation, so all subclasses of caanimation can use them.
2. Other
* Capropertyanimation is also not directly used, but also to use its subclasses
* Therefore, only 4 of the animated classes are available: Cabasicanimation, Cakeyframeanimation, Catransition, Caanimationgroup
Back to the top four, capropertyanimation
* Capropertyanimation is a subclass of caanimation, but cannot be used directly, to create an animated object, you should use its two subclasses: Cabasicanimation and Cakeyframeanimation
* It has a nsstring type of KeyPath property, you can specify that a property of Calayer is named KeyPath, and the value of this property of Calayer is modified to achieve the corresponding animation effect. For example, specifying @ "position" for KeyPath will modify the value of the position property of the Calayer to achieve a panning animation effect
* Therefore, after initializing the Capropertyanimation subclass object, you must set the KeyPath, figure out which property to modify Calayer, and what kind of animation to perform.
OC Language Knowledge 9