转场动画是一种动画对象,可以被附着在已经存在的视图上。
需导入Quartz Qore框架
- #import <QuatzCore/CAAnimation.h>
- CATransition *myTransition=[CATransition animation];
- myTransition.duration=0.3;
- myTransition.timingFunction=UIViewAnimationCurveEaseInOut;
- myTransition.type=kCATransionPush;
- myTransition.subtype=kCATransitionFromLeft;
-
- [[self.view.superview layer]addAnimation:myTransition forKey:nil ];
-
- [ self.view.layer addAnimation:myTransition forKey:nil ];
- [ self.view addSubView:newView ];
- [oldView removeFromSuperview];
-
- [ navigationController.view.layer addAnimation:myTransition forKey:nil ];