注:UIView动画的产生基于CALayer

UIView Animation 基本动画 

UIView类扩展实现动画实际就是通过修改视图⼀一些动画属性:在设定时间内反复或逐步完成这 些修改操作以达到动画展现的效果。

动画属性如下:

1. frame,bounds,center //改变View的frame属性
2. alpha //改变透明度
3. backgroundColor //改变背景颜⾊色
4. transform//仿射变换,其中包括Rotate,Translate,Scale(旋转,位移,缩放)

普通的动画都是帧每秒,⾁肉眼能识别的是帧每秒,⽽而在游戏上会要求是帧每秒。 

 

iOS4之前的UIView Animation实现⽅方式 

[UIView beginAnimations:@"ToggleViews" context:nil];
[UIView setAnimationDuration:1.f];
self.animationView.alpha = 0.f;
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finish
ed:context:)];
[UIView commitAnimatioins];
iOS4之后官⽅方更推荐使⽤用block实现UIView Animation 

 弹簧动画:

        * duration: 动画时长

             * delay: 动画延时开始的时间

             * Damping: 弹簧的阻尼系数 (0-1) 1:最大阻尼,没有弹簧效果

             * velocity: 初始动力大小 通常设置为0,系统会根据duration和damping自动调整弹簧效果

[UIView animateWithDuration:5.f
     usingSpringWithDamping:.3f
      initialSpringVelocity:.2f
                      delay:0.f
                    options:UIViewAnimationOptionAllowUserInteraction
                 animations:^{
                     self.animationView.center = CGPointMake(160, 450);
                                                             } completion:^(BOOL finished) {
                                                                 }];

 

posted on 2015-10-11 18:44  怡情_老二  阅读(134)  评论(0)    收藏  举报