Core Animation-One

Animate the content of the layer

Core AnimationThe provided infrastructure makes it incredibly easy to easily animate complex layers, Core Animationextending all views that have layers. For example, change the size of the layer's frame rectangle, change its position on the screen, apply a rotation transform, and change its transparency. Initializing Core Animationan animation is as easy as changing a property, but you can also explicitly create an animation and set the parameters of the animation.

Animate changes to layer properties with simple animations
You can perform simple animations explicitly or implicitly. Implicit animations use default timers and animation properties to perform animations. Explicit animations require you to configure some parameters for the animation object. So when the default timer works well for you and the animation you want doesn't require a lot of code, implicit animation is perfect for you.

Simple animations involve changing the properties of a layer and animating those changes over time Core Animation. Layers define a number of properties that affect the visual appearance of the layer. Changing these properties is a way to animate the change in appearance. For example, changing the transparency of the layer from 1.0 to 0.0 will cause the layer to fade out, and finally the layer will become transparent.

Important : While you can Core Animationdirectly animate a layer-backed view using an interface, doing so often requires additional steps.

In order to trigger the implicit animation, all you have to do is update the properties of the layer object. When the target of the change is a layer object in the layer tree, the change will be reflected on the object immediately. While the visual appearance of the layer object does not change immediately, the change in Core Animationthe properties of the layer object is used as a trigger to create and schedule one or more implicit animations that can be performed. Modifying the layer object properties, as in Listing 3-1, will cause Core Animationthe animation object to be created for you, and the animation object will be scheduled to run on the next update cycle.

Listing 3-1 Implicit animation for changes to layer properties

theLayer.opacity = 0.0; 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325504326&siteId=291194637