How do I pause all animations in a layer tree?
2013-01-28 17:26
465 查看
A: In order to pause animations in a layer tree, you can take advantage of the fact that a
Listing 1 Pause and Resume animations.
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 do I pause execution in JavaScript?
- How do I commit all deleted files in Git?
- How do I list all fields of an object in Objective-C?
- How do I list all tables/indices contained in an SQLite database
- How to implement collapse all in windows tree structure such as regedit
- [转]How to Use xp_dirtree to List All Files in a Folder
- How to delete all the animations in a presentation
- How to pause the animation of a layer tree
- How do I configure glibc in a separate build folder ?与 Glibc 安装指南
- How do I sort an array of hashes by a value in the hash?
- How do I join two lists in Java?
- (在做报文编辑器时右键菜单老不出来)This article explains how to display a context menu for a tree control in MFC
- How do I add multiple arguments to my custom template filter in a django template? - Stack Overflow
- FAQ How do I write to the console from a plug-in?
- How do you get the length of a string in jQuery?
- How do I make my GUI plot into an axes within the GUI figure rather than inside of a new figure in M
- How do I use “slice_before” with initial_state in Ruby 1.9?
- In Java, how do I read/convert an InputStream to a String? - Stack Overflow
- What is a "sosreport" and how do I create it in Red Hat Enterprise Linux 4.6 and later
- Ogre : How to actually get morph animations to work in the engine