Statement You are welcome to repost this article, but please respect the author's Labor achievements. repost this article and keep the statement in this box. Thank you. ArticleSource: http://blog.csdn.net/iukey |
First recommend a post: http://www.cocoachina.com/bbs/read.php? Tid-10972.html
An animation object can be attached to an existing view.
Import the quartz qore framework
# Import <quatzcore/caanimation. h> catransition * mytransition = [catransition animation]; // create catransitionmytransition. duration = 0.3; // Duration: 0.3 seconds mytransition. timingfunction = uiviewanimationcurveeaseinout; // timing function, smooth from start to end mytransition. type = kcatransionpush; // animation type mytransition. subtype = kcatransitionfromleft; // subtype // to make an animation take effect, add the animation to the layer to be attached to the animation view. For example, to transfer an animation between two view controllers, add the animation to the window layer: [[self. view. superview layer] addanimation: mytransition forkey: Nil]; // if you want to transfer the subview in the Controller to another subview, add the animation to the layer of the View Controller. Another option is to use the internal view of the View Controller as an alternative, and use your child view as the child layer of the main view: [self. view. layer addanimation: mytransition forkey: Nil]; [self. view addsubview: newview]; [oldview removefromsuperview]; // if you are using a navigation controller, add the animation to the view layer of the navigation controller. [Navigationcontroller. View. layer addanimation: mytransition forkey: Nil];