UIView animation

UIView的动画其实很不复杂,但是流程老忘记,几个笔记

看过官方文档的都知道,官方推荐在iOS4以后使用[UIView animateWithDuration:animations:],而不是原来的[UIView beginAnimations:context:],来完成动画,虽然二者功能几乎完全相同,但使用前者在一些情况下会方便不少,这些内容可以参考官方文档View Programming Guide For iOS的Animation一节.

二者有一个值得新手注意的区别就是[UIView animateWithDuration:animations:]默认会禁止触摸,手势等的响应,这可以通过设置option选项来解决(直接引用StackOverFlow的一段了):

UIViewAnimationOptions options = UIViewAnimationCurveLinear | UIViewAnimationOptionAllowUserInteraction;

 

[UIView animateWithDuration:0.2 delay:0.0 options:options animations:^

 {

     highlightView.alpha = 1.0;

 

 } completion:nil];


、、

[UIView animateWithDuration:duration

                          delay:0.0

                        options:UIViewAnimationCurveEaseInOut //设置动画类型

                     animations:^{

                         //开始动画

                         [self updateArrowBtnTitle:YES];

                         rotateView.transform = CGAffineTransformMakeRotation((stickToDegrees/180)*M_PI);

                     }

                     completion:^(BOOL finished){

                         // 动画结束时的处理

                     }];

[UIView animateWithDuration:] 方法仅支持ios4.0及以上版本。如果要兼容以前的版本的话,还是需要使用 [UIView beginAnimation:] 方法

[UIView beginAnimations:nil context:nil];

    // fade out

    helpImageBtn.alpha = 0.0f;

    // set animation did stop selector

    [UIView setAnimationDelegate:self];

    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];

    [UIView commitAnimations];


   - (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {

    if (self.retainedHelpImageBtn.superview) //先判断父视图再执行视图移除

        [self.retainedHelpImageBtn removeFromSuperview];

   }

FROM:http://blog.csdn.net/zhanglei5415/article/details/7006626 

原文地址:https://www.cnblogs.com/likwo/p/2654849.html