UIView的动画可以改变如下属性:
The following properties of the UIView
class are animatable:
@property frame
@property bounds
@property center
@property transform
@property alpha
@property backgroundColor
@property contentStretch
实现动画的方式apple文档推荐用block的形式而不推荐用creat然后commit的形式,注:block形式需要4.0以后才可以用,使用方法如下:
animateWithDuration:delay:options:animations:completion:
举个例子:
[UIView animateWithDuration:0.5//动画持续时间
delay:0//动画延迟执行时间
options:UIViewAnimationCurveEaseOut//动画曲线
animations:^{
[myView setAlpha:1];//动画部分
} completion:^(BOOL finished) {
NSlog(@”animation finished”);//动画结束后回调函数
}];
常用这种形式,关键参数很明显,如果要嵌套动画的话就在completion方法里面,把NSlog替换成一组新的blok动画代码就可以了,举例:
[UIView animateWithDuration:0.5//动画持续时间
delay:0//动画延迟执行时间
options:UIViewAnimationCurveEaseOut//动画曲线
animations:^{
[myView setAlpha:1];//动画部分
} completion:^(BOOL finished) {//第一个动画结束后执行的动画
[UIView animateWithDuration:0.5
delay:0
options:UIViewAnimationCurveEaseOut
animations:^{
[myView setAlpha:0];
} completion:^(BOOL finished) {
NSlog(@”animation finished”);
}];
}];