ios 动画系列之一------简单动画的实现
2013-07-22 10:37
429 查看
实现ios动画,主要有两种方法:UIView层面上的、使用CATransition。
一、UIView层面上的
以beginAnimations:开始,以commitAnimations结束,关于动画的一切设置都写在这两个方法之间,不然无效。
二、使用CATransition
这里有两个属性要注意,type,Subtype,一般都是把这两个属性组合使用,我们来看一下官方对这两个属性的解释。
1、@property(copy) NSString *type;
type是这个transition的名字,当前合法的transition类型包括:`fade', `moveIn', `push' and `reveal',默认是`fade'。
它公开的类型可以有:淡化、移入、推挤、覆盖
2、@property(copy) NSString *subtype;
subtype是这个transition可选的类型,比如,用来区分这个transition的方向,合法的值有`fromLeft', `fromRight', `fromTop' and * `fromBottom'.
它公开的类型可以有:
3、本来没什么疑问,看到这个说明后,反而觉得奇怪,如果type只有这么几个类型,那cube、page等都是在哪实现的了?
cube等效果都不是它公开的方法,而是它提供的私有类型。
这些私有类型尽量少用。
4、CATransition的startProgress endProgress属性
这两个属性用来控制动画开始的点和结束的点,值在0.0--0.1之间。这个控制开始和结束的点,意思就是让动画不是从起点开始,而是从某一点开始,到某一点就停止动画效果,不是画面停止,而是动画效果停止。感觉没说清楚,这个自己试一下就知道了。
我们将在下一节详细介绍ios动画的各个属性设置。
一、UIView层面上的
[UIView beginAnimations:@"animation" context:nil]; [UIView setAnimationDuration:1.0f]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES]; //交换本视图控制器中2个view位置 [self.view exchangeSubviewAtIndex:2 withSubviewAtIndex:1]; [UIView setAnimationDidStopSelector:@selector(animationFinish:)]; [UIView commitAnimations];
以beginAnimations:开始,以commitAnimations结束,关于动画的一切设置都写在这两个方法之间,不然无效。
二、使用CATransition
CATransition *transition = [CATransition animation]; transition.duration = 2.0f; transition.type = @"cube"; transition.subtype = kCATransitionFromLeft; [self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:0]; [self.view.layer addAnimation:transition forKey:@"animation"];
这里有两个属性要注意,type,Subtype,一般都是把这两个属性组合使用,我们来看一下官方对这两个属性的解释。
1、@property(copy) NSString *type;
type是这个transition的名字,当前合法的transition类型包括:`fade', `moveIn', `push' and `reveal',默认是`fade'。
它公开的类型可以有:淡化、移入、推挤、覆盖
NSString * const kCATransitionFade; NSString * const kCATransitionMoveIn; NSString * const kCATransitionPush; NSString * const kCATransitionReveal;
2、@property(copy) NSString *subtype;
subtype是这个transition可选的类型,比如,用来区分这个transition的方向,合法的值有`fromLeft', `fromRight', `fromTop' and * `fromBottom'.
它公开的类型可以有:
NSString * const kCATransitionFromRight; NSString * const kCATransitionFromLeft; NSString * const kCATransitionFromTop; NSString * const kCATransitionFromBottom;
3、本来没什么疑问,看到这个说明后,反而觉得奇怪,如果type只有这么几个类型,那cube、page等都是在哪实现的了?
cube等效果都不是它公开的方法,而是它提供的私有类型。
animation.type = @"cube" ; //立方体翻转 animation.type = @"suckEffect"; //收缩效果,如一块布被抽走 animation.type = @"oglFlip";//上下翻转效果,不管subType is "fromLeft" or "fromRight",official只有一种效果 animation.type = @"rippleEffect"; //滴水效果 animation.type = @"pageCurl"; //向上翻一页 animation.type = @"pageUnCurl" //向下翻一页 animation.type = @"cameraIrisHollowOpen "; //类似于ios的相机打开时的效果 animation.type = @"cameraIrisHollowClose "; //类似于ios的相机关闭时的效果
这些私有类型尽量少用。
4、CATransition的startProgress endProgress属性
这两个属性用来控制动画开始的点和结束的点,值在0.0--0.1之间。这个控制开始和结束的点,意思就是让动画不是从起点开始,而是从某一点开始,到某一点就停止动画效果,不是画面停止,而是动画效果停止。感觉没说清楚,这个自己试一下就知道了。
我们将在下一节详细介绍ios动画的各个属性设置。
相关文章推荐
- iOS 简单实现gif动画播放
- iOS UIImageview实现简单动画
- 【iOS开发-50】利用创建新的类实现代码封装,从而不知不觉实践一个简单的MVC实验,附带个动画
- IOS开发-CGAffineTransform的用法,实现一些简单动画效果
- iOS-实现简单的动画效果
- ios开发之简单实现loading动画效果
- iOS动画系列之九:实现点赞的动画及播放起伏指示器
- IOS中UIView动画的简单实现
- IOS系列——ScrollView大放大和缩小功能的简单实现
- iOS简单的动画效果实现
- iOS TableView给力动画的简单实现
- iOS 进度条、加载、安装动画的简单实现
- 【iOS开展-50】使用它来创建一个新的类的实现代码包,因此,不自觉地练习简单MVC实验,附带动画
- iOS --用CABasicAnimation实现简单的动画效果
- iOS 实现简单的加载等待动画示例(思路与实现)
- ios简单动画的实现
- ios高级动画的简单实现
- iOS 碎片动画简单实现
- Android UI设计系列之自定义SwitchButton开关实现类似IOS中UISwitch的动画效果(2)
- IOS中UIImageView方法实现简单动画