• [UIView beginAnimations:context:]与[UIView animateWithDuration:animations:]值得注意的一个区别


    原文链接:http://longtimenoc.com/archives/uiview-beginanimationscontext%E4%B8%8Euiview-animatewithdurationanimations%E5%80%BC%E5%BE%97%E6%B3%A8%E6%84%8F%E7%9A%84%E4%B8%80%E4%B8%AA%E5%8C%BA%E5%88%AB


    看过官方文档的都知道,官方推荐在iOS4以后使用[UIView animateWithDuration:animations:],而不是原来的[UIView beginAnimations:context:],来完成动画,虽然二者功能几乎完全相同,但使用前者在一些情况下会方便不少,这些内容可以参考官方文档View Programming Guide For iOS的Animation一节.
    二者有一个值得新手注意的区别就是[UIView animateWithDuration:animations:]默认会禁止触摸,手势等的响应,这可以通过设置option选项来解决(直接引用StackOverFlow的一段了):

    1. UIViewAnimationOptions options = UIViewAnimationCurveLinear | UIViewAnimationOptionAllowUserInteraction;  
    2.    
    3. [UIView animateWithDuration:0.2 delay:0.0 options:options animations:^  
    4.  {  
    5.      highlightView.alpha = 1.0;  
    6.    
    7.  } completion:nil];  

    就是这么一点事儿,害我走了不少弯路(我也是新手哈),在这里写一下,提示一下有可能遇到同样问题的人.

     

    1. [UIView animateWithDuration:duration  
    2.                           delay:0.0  
    3.                         options:UIViewAnimationCurveEaseInOut //设置动画类型  
    4.                      animations:^{  
    5.                          //开始动画  
    6.                          [self updateArrowBtnTitle:YES];  
    7.                          rotateView.transform = CGAffineTransformMakeRotation((stickToDegrees/180)*M_PI);  
    8.                      }  
    9.                      completion:^(BOOL finished){  
    10.                          // 动画结束时的处理  
    11.                      }];  

     

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

      1. [UIView beginAnimations:nil context:nil];  
      2.     // fade out  
      3.     helpImageBtn.alpha = 0.0f;  
      4.     // set animation did stop selector  
      5.     [UIView setAnimationDelegate:self];  
      6.     [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];  
      7.     [UIView commitAnimations];  
      8.   
      9.    - (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {  
      10.     if (self.retainedHelpImageBtn.superview) //先判断父视图再执行视图移除  
      11.         [self.retainedHelpImageBtn removeFromSuperview];  
      12.    }  
  • 相关阅读:
    ArcGIS 9.4的技术展望 (转)
    逻辑斯蒂方程的应用
    Logistic混沌映射(转)
    投入产出分析的应用和编制方法
    在matlab中实现逻辑斯蒂映射
    国内的城市GIS面临的机遇和挑战(转载)
    arcgis中曼哈顿距离、路网距离、near工具、Point Distance工具的使用
    apache no services installed 安装apache后没有服务
    LoadRunner录制脚本问题收集
    16进制枚举值 转换为枚举类型
  • 原文地址:https://www.cnblogs.com/heyonggang/p/3494468.html
Copyright © 2020-2023  润新知