IOS中各种动画特效的实现
2015-12-23 09:27
615 查看
第一类动画特效:
这类特效有四种,在UIView中就可以实现,分别为CurlDown,CurlUp,FilpFromLeft,FilpFromRight。在视图切换之前设置UIView,如下:
[UIView
beginAnimations:@"Animation" context:nil];
[UIView setAnimationDuration:0.5];//设置动画持续时间;
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
接下来设置动画特效,有四种特效可供选择:
[UIView
setAnimationTransition:UIViewAnimationTransitionCurlDown
forView:self.view cache:YES];
[UIView
setAnimationTransition:UIViewAnimationTransitionCurlUp
forView:self.view cache:YES];
[UIView
setAnimationTransition:UIViewAnimationTransitionFilpFromLeft forView:self.view
cache:YES];
[UIView
setAnimationTransition:UIViewAnimationTransitionFilpFromRight forView:self.view
cache:YES];
之后就可以切换view了,最后执行动画:
[UIView commitAnimations];
第二类动画特效:
这类动画特效需要用到QuartzCore.framework,单击工程,点击Build
Phases,找到Link Binary With
Libraries,点击下面的+号,找到QuartzCore.framework添加即可。
同样,在view切换之前需要做一些设置:
CATransition
*animation = [CATransition
animation]; //声明动画对象;
animation.delegate = self;
animation.duration = kDuration;//设置动画持续时间;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
然后就可以选择动画类型,大概有十二种动画:
animation.type = kCATransitionFade;
animation.type = kCATransitionPush;
animation.type = kCATransitionReveal;
animation.type = kCATransitionMoveIn;
animation.type = @"cube";
animation.type = @"suckEffect";
animation.type = @"oglFlip";
animation.type = @"rippleEffect";
animation.type = @"pageCurl";
animation.type = @"pageUnCurl";
animation.type = @"cameraIrisHollowOpen";
animation.type = @"cameraIrisHollowClose";
任选其中一种。同时也可以设置animation的subtype,用以设置动画运行的方向,如:
animation.subtype
= kCATransitionFromLeft;
animation.subtype
= kCATransitionFromBottom;
animation.subtype
= kCATransitionFromRight;
animation.subtype
= kCATransitionFromTop;
之后是切换view,最后还要添加一句代码:
[[self.view layer] addAnimation:animation
forKey:@"animation"];
这类特效有四种,在UIView中就可以实现,分别为CurlDown,CurlUp,FilpFromLeft,FilpFromRight。在视图切换之前设置UIView,如下:
[UIView
beginAnimations:@"Animation" context:nil];
[UIView setAnimationDuration:0.5];//设置动画持续时间;
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
接下来设置动画特效,有四种特效可供选择:
[UIView
setAnimationTransition:UIViewAnimationTransitionCurlDown
forView:self.view cache:YES];
[UIView
setAnimationTransition:UIViewAnimationTransitionCurlUp
forView:self.view cache:YES];
[UIView
setAnimationTransition:UIViewAnimationTransitionFilpFromLeft forView:self.view
cache:YES];
[UIView
setAnimationTransition:UIViewAnimationTransitionFilpFromRight forView:self.view
cache:YES];
之后就可以切换view了,最后执行动画:
[UIView commitAnimations];
第二类动画特效:
这类动画特效需要用到QuartzCore.framework,单击工程,点击Build
Phases,找到Link Binary With
Libraries,点击下面的+号,找到QuartzCore.framework添加即可。
同样,在view切换之前需要做一些设置:
CATransition
*animation = [CATransition
animation]; //声明动画对象;
animation.delegate = self;
animation.duration = kDuration;//设置动画持续时间;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
然后就可以选择动画类型,大概有十二种动画:
animation.type = kCATransitionFade;
animation.type = kCATransitionPush;
animation.type = kCATransitionReveal;
animation.type = kCATransitionMoveIn;
animation.type = @"cube";
animation.type = @"suckEffect";
animation.type = @"oglFlip";
animation.type = @"rippleEffect";
animation.type = @"pageCurl";
animation.type = @"pageUnCurl";
animation.type = @"cameraIrisHollowOpen";
animation.type = @"cameraIrisHollowClose";
任选其中一种。同时也可以设置animation的subtype,用以设置动画运行的方向,如:
animation.subtype
= kCATransitionFromLeft;
animation.subtype
= kCATransitionFromBottom;
animation.subtype
= kCATransitionFromRight;
animation.subtype
= kCATransitionFromTop;
之后是切换view,最后还要添加一句代码:
[[self.view layer] addAnimation:animation
forKey:@"animation"];
相关文章推荐
- 详解iOS开发中app的归档以及偏好设置的存储方式
- IOS中通知中心(NSNotificationCenter)的使用总结
- mac 操作系统 ios操作系统
- 开发使用 iBeacon 的 iOS 7 应用
- 统计iOS工程代码行数
- iOS开发 关于iBeacon
- iOS开发—获取系统键盘高度
- IOS视频播放器VKVideoPlayer简单教程
- iosclient暑期“动画屋“活动项目总结
- iOS-QuartzCore(CAAnimation.h--解读)
- iOS导航控制器
- iOS navigationcontroller 的导航条的设置
- iOS各个版本的特点
- IOS 动画组
- IOS CALayer
- IOS 逐帧动画
- IOS 转场动画 -CATransition
- iOS- GCD总结
- iOS - block语法块
- 史上最全Xcode快捷键还有Mac的呢 适用于 IOS开发者