Common types in iOS core animations

Source: Internet
Author: User

Catransaction

When we modify some properties that support animation on a custom layer, the system automatically animates the modification of that property. This is actually an implicit animation. Implicit animations benefit from catransaction. A catransaction begins with the call to Catransaction.begin () and ends with Catransaction.commit (). In the meantime, the modification of the layer properties will be controlled by the transaction, and the duration of transaction can be modified by setanimationduration.

The implicit animation of the system is because in each cycle of runloop, the system automatically calls the Catransaction.begin () and Commit () methods, and the default duration is 0.25 seconds. Of course we can also put our own transaction in code by calling begin () to define different configurations.

However, the UIView associated layer is by default the implicit animation feature is forbidden. So the system provides us with the Uiview.animationwithduration method. In fact, the Catransaction.begin () and commit () methods are called internally to implement.

Cabasicanimation/cakeyframesanimation

These two classes are capropertyanimation derived classes that are used to explicitly animate a property.

Cabasicanimation: You can configure Fromvalue,tovalue to define over-animation from Fromvalue to Tovalue.

Cakeyframesanimation: You can configure keytimes and values to define a set of key values and corresponding time nodes to define transition animations between these key values

All two of these classes are rendered with only one transition effect, and when the animation finishes, the value of the property remains unchanged. You need to set the delegate of the animation object and implement it in the delegate object

Override func animationdidstop (anim: caanimation, finished flag: Bool) to accept notification of the end of the animation, Here to finally change the value of the property.

Catransition

For properties that do not support animation, we can use catransition to create transitions using predefined animations. My understanding is that transition will apply to all the changes that have been generated on the layer in the current runloop cycle, the newly added layers, the changes in the properties ....

Transition has several key properties

The Type property defines the types of animations to apply, with the following options:

1. System-defined constants
Kcatransitionfade Cross-fade transitions
Kcatransitionmovein New view above old view
Kcatransitionpush New View roll out the old view
Kcatransitionreveal move the old view away to show the new view below

2. The system is not defined as a constant and is represented by a string
Pagecurl PAGE Up
Pageuncurl PAGE Down
Rippleeffect drip Effect
Suckeffect shrinkage effect, as a piece of cloth is pumped away
Cube Cube Effect
Oglflip up/down rollover effect

The Subtype property is used to define the direction of animation for some types, with the following values optional:

Kcatransitionfromtop

Kcatransitionfrombottom

Kcatransitionfromright

Kcatransitionfromleft

Common types in iOS core animations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.