几乎所有关于动画的设置方法,在动画块外没有任何效果。使用beginAnimations:context: 类方法来开始一个动画块并用commitAnimations类方法结束
1、areAnimationsEnabled
返回一个布尔值表示是否允许动画效果 + (BOOL)areAnimationsEnabled
2、beginAnimations:context:
开始一个动画块 + (void)beginAnimations:(NSString *)animationID context:(void *)context
一般调用方式:[UIViewbeginAnimations:@"animation" context:nil];
参数
animationID
动画块内部应用程序标识用来传递给动画代理消息-这个选择器运用setAnimationWillStartSelector:和setAnimationDidStopSelector: 方法来设置。
context
附加的应用程序信息用来传递给动画代理消息-这个选择器使用setAnimationWillStartSelector: 和setAnimationDidStopSelector: 方法。
3、commitAnimations
结束一个动画块。+ (void)commitAnimations
一般调用方式:[UIViewcommitAnimations];
如果当前的动画块是最外层的动画块,当应用程序返回到循环运行时开始动画块。动画在一个独立的线程中所有应用程序不会中断。使用这个方法,多个动画可以被实现。查看setAnimationBeginsFromCurrentState:来了解如果开始一个动画当另外一个动画在播放的时候。
4、layerClass
用来创建这一个本类的layer实例对象。+ (Class)layerClass
当在创建视图layer时候调用。默认的值是CALayer类对象。
5、setAnimationBeginsFromCurrentState:
设置动画从当前状态开始播放。 + (void)setAnimationBeginsFromCurrentState:(BOOL)fromCurrentState
参数
fromCurrentState :YES如果动画需要从他们当前状态开始播放。否则为NO。
讨论
如果设置为YES,那么当动画在运行过程中,当前视图的位置将会作为新的动画的开始状态。如果设置为NO,当前动画结束前新动画将使用视图最後状态的位置作为开始状态。这个方法将不会做任何事情如果动画没有运行或者没有在动画块外调用。
6、setAnimationCurve:
设置动画块中的动画属性变化的曲线。 + (void)setAnimationCurve:(UIViewAnimationCurve)curve
一般调用方式:[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
讨论
动画曲线是动画运行过程中相对的速度。如果在动画块外调用这个方法将会无效。默认动画曲线的值是UIViewAnimationCurveEaseInOut。
参数列表:
typedef NS_ENUM(NSInteger, UIViewAnimationCurve) { UIViewAnimationCurveEaseInOut, // slow at beginning and end UIViewAnimationCurveEaseIn, // slow at beginning UIViewAnimationCurveEaseOut, // slow at end UIViewAnimationCurveLinear };
7、setAnimationDelay:
在动画块中设置动画的延迟属性(以秒为单位)
8、setAnimationDelegate:
设置动画消息的代理。
+ (void)setAnimationDelegate:(id)delegate
参数
delegate
你可以用setAnimationWillStartSelector:和setAnimationDidStopSelector: 方法来设置接收代理消息的对象。
9、setAnimationDidStopSelector:
当动画结束时,发送一条消息到动画代理
+ (void)setAnimationDidStopSelector:(SEL)selector
参数
selector
当动画结束的时候发送给动画代理。默认值是NULL。这个选择者须有下面方法的签名:animationFinished:(NSString *)animationID finished:(BOOL)finished context:(void *)context。
animationID
一个应用程序提供的标识符。和传给beginAnimations:context: 相同的参数。这个参数可以为空。
finished
如果动画在停止前完成那返回YES;否则就是NO。
context
一个可选的应用程序内容提供者。和beginAnimations:context: 方法相同的参数。可以为空。
10、setAnimationDuration:
设置动画块中的动画持续时间(用秒)
+ (void)setAnimationDuration:(NSTimeInterval)duration
11、setAnimationRepeatAutoreverses:
设置动画块中的动画效果是否自动重复播放。
+ (void)setAnimationRepeatAutoreverses:(BOOL)repeatAutoreverses
参数
repeatAutoreverses
如果动画自动重复就是YES否则就是NO。
讨论
自动重复是当动画向前播放结束後再重头开始播放。使用setAnimationRepeatCount: 类方法来指定动画自动重播的时间。如果重复数为0或者在动画块外那将没有任何效果。
12、setAnimationRepeatCount:
设置动画在动画模块中的重复次数
+ (void)setAnimationRepeatCount:(float)repeatCount
参数
repeatCount
动画重复的次数,这个值可以是分数。
13、setAnimationsEnabled:
设置是否激活动画
+ (void)setAnimationsEnabled:(BOOL)enabled
参数
enabled
如果是YES那就激活动画;否则就是NO
讨论
当动画参数没有被激活那么动画属性的改变将被忽略。默认动画是被激活的。
14、setAnimationStartDate:
设置在动画块内部动画属性改变的开始时间
+ (void)setAnimationStartDate:(NSDate *)startTime
参数
startTime
一个开始动画的时间
讨论
使用beginAnimations:context:类方法来开始一个动画块并用commitAnimations类方法来结束动画块。默认的开始时间值由CFAbsoluteTimeGetCurrent方法来返回。
15、setAnimationTransition:forView:cache:
在动画块中为视图设置过渡
+ (void)setAnimationTransition:(UIViewAnimationTransition)transition forView:(UIView *)view cache:(BOOL)cache
一般调用方式:[UIView setAnimationTransition:UIViewAnimationTransitionCurlDownforView:self.viewcache:YES];
参数
transition
把一个过渡效果应用到视图中。可能的值定义在UIViewAnimationTransition中。
view
需要过渡的视图对象。
cache
如果是YES,那么在开始和结束图片视图渲染一次并在动画中创建帧;否则,视图将会在每一帧都渲染。例如缓存,你不需要在视图转变中不停的更新,你只需要等到转换完成再去更新视图。
setAnimationTransition的参数列表:
typedef NS_ENUM(NSInteger, UIViewAnimationTransition) {
UIViewAnimationTransitionNone,
UIViewAnimationTransitionFlipFromLeft,
UIViewAnimationTransitionFlipFromRight,
UIViewAnimationTransitionCurlUp,
UIViewAnimationTransitionCurlDown,
};
16、setAnimationWillStartSelector:
当动画将开始时,发送一条消息到动画代理
+ (void)setAnimationWillStartSelector:(SEL)selector
参数
selector
在动画开始前向动画代理发送消息。默认值是NULL。这个selector必须由和beginAnimations:context: 方法相同的参数,一个任选的程序标识和内容。这些参数都可以是nil。