zoukankan      html  css  js  c++  java
  • 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 

  • 相关阅读:
    [Python] Array Attributes of Numpy lib
    《火球——UML大战需求分析》(第2章 耗尽脑汁的需求分析工作)——2.1 需求分析面面观
    UVA 10201 Adventures in Moving
    《史蒂夫·乔布斯传》官方正式中文版电子书(高清晰完整版)
    为什么要用BitSet
    sed 技巧一例:特定位置插入
    Mac+IPAD上使用wireshark抓包
    【经验谈】XmlSerializer的坑
    HTML语言简单回顾
    不可思议的每日培训(1)——日复一日的每日分享
  • 原文地址:https://www.cnblogs.com/likwo/p/2654849.html
Copyright © 2011-2022 走看看