UIView Animation
UIView Animation 基本动画
UIView类扩展实现动画实际就是通过修改视图一些动画属性:在设定时间内反复或逐步完成这些修改操作以达到动画展现的效果。
基本动画效果
动画属性如下:
- frame,bounds,center //改变View的frame属性
- alpha //改变透明度
- backgroundColor //改变背景颜色
- transform//仿射变换,其中包括Rotate,Translate,Scale(旋转,位移,缩放)
普通的动画都是30帧每秒,肉眼能识别的是24帧每秒,而在游戏上会要求是60帧每秒。
iOS4之前的UIView Animation实现方式
[UIView beginAnimations:@"ToggleViews" context:nil];
[UIView setAnimationDuration:1.f];
self.animationView.alpha = 0.f;
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView commitAnimations];
iOS4之后官方更推荐使用block实现UIView Animation
[UIView animateWithDuration:5.f
delay:0.f
usingSpringWithDamping:.3f
initialSpringVelocity:.2f
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
self.animationView.center = CGPointMake(160, 450);
} completion:^(BOOL finished) {
//动画结束的回调
}];