How to pause the animation of a layer tree
2013-09-13 10:26
417 查看
From: http://www.devdiv.com/how_to_pause_the_animation_of_a_layer_tree-blog-21666-51864.html
A: In order to pause animations in a layer tree, you can take advantage of the fact that a
The
layer. Listing 1 demonstrates how you can do this.
Listing 1 Pause and Resume animations.
Q: How do I pause all animations in a layer tree?
A: In order to pause animations in a layer tree, you can take advantage of the fact that a CALayerconforms to the
CAMediaTimingprotocol.
The
CAMediaTimingprotocol defines, among other things, a speed with which its timeline progresses, which you can use to pause all animations on the target
layer. Listing 1 demonstrates how you can do this.
Listing 1 Pause and Resume animations.
-(void)pauseLayer:(CALayer*)layer { CFTimeInterval pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil]; layer.speed = 0.0; layer.timeOffset = pausedTime; } -(void)resumeLayer:(CALayer*)layer { CFTimeInterval pausedTime = [layer timeOffset]; layer.speed = 1.0; layer.timeOffset = 0.0; layer.beginTime = 0.0; CFTimeInterval timeSincePause = [layer convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime; layer.beginTime = timeSincePause; }
相关文章推荐
- How to pause or end a UIView animation via the CALayer
- 如何解决flash跑到层上面的问题?How to resolve the div layer appear over the top of flash?
- RadTreeView: How to Wrapping the text of tree nodes
- How to popup a UIPickerView from the bottom of a UIScrollView in response to UITextField selection
- How to customize the background color of a UITableViewCell?
- How to Enable Trace or Debug for APIs executed as SQL Script Outside of the Applications ?
- Agile Project Management: How to Succeed in the Face of Changing Project Requirements
- How to use the JFace Tree Viewer(TreeViewer)--1
- How to implement the built in effects of DirectX.DirectSound
- How to choose the number oftopics/partitions in a Kafka cluster?
- How to eliminate the compile error "conversion from 'double ' to 'float ', possible loss of data"
- how to get the space size of some tables in one database?
- How to Determine the Version of Oracle XML Publisher for Oracle E-Business Suite 11i and Release 12 (Doc ID 362496.1)
- How to get IOleSite interface of the WebBrowser in an ActiveX control
- 如何访问Azure上的SharePoint 网站(How to access the SharePoint site of Azure)
- How to craw the Info of BiliBIli with python
- 1. How to Inspect the Content of a Program Data...
- How to get the visible region of a window or CDC(转自http://www.programmersheaven.com)
- [jQuery] 如何根据名字来选取checkbox数组 -- How to get the array of checkbox via name