动画 animation
[UIView beginAnimations:@"trun" context:nil];//开始一个动画 [UIView setAnimationDuration:1]; //动画的时间 [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];//动画的曲线 [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];//从右侧开始水平翻转 [self.view addSubview:self.viewController.view];//加载到主视图中 [UIView commitAnimations]; //提交动画
动画的几种效果:
左翻转 UIViewAnimationTransitionFlipFromLeft;
在翻转 UIViewAnimationTransitionFlipFromRight;
往上翻 UIViewAnimationTransitionCurlUp;
往下翻 UIViewAnimationTransitionCurlDown;
2.CATransition
CATransition *transition=[CATransition animation]; transition.duration=1;//持续时间 transition.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];/ transition.type=kCATransitionMoveIn;/动画过渡的种类 transition.subtype=kCATransitionFromBottom;//动画过渡的方向 [self.view.layer addAnimation:transition forKey:nil];//在主界面View的layer添加动画
type为动画过渡的类型,
KCATransitionFade 淡出
KCATransitionMoveIn 覆盖原图
KCATransitionPush 推出
KCATransitionReveal 底部显出来
subType类型:
kCATransitionFromRight 从右侧翻转
kCATransitionFromLeft
kCATransitionFromTop
kCATransitionFromBottom
另外的动画:
[transition setType=@"suckEffect"];
pageCurl 向上翻一面
pageUnCurl 向下
rippleEffect 水滴
suckEffect 收缩效果
cube 立方体效果
oglFlip 上下翻转效果