zoukankan      html  css  js  c++  java
  • Animations--动画基础

    基础动画

    //1.在0.5s内,将_field.alpha 的数值变为1.0
    [UIView animateWithDuration:0.5 animations:^{
       _field.alpha = 1.0;
    }];
    
    //2. 较1,在动画完成后,输出log:animation finished!
    [UIView animateWithDuration:0.5 animations:^{
       _field.alpha = 1.0;
    } completion:^(BOOL finished) { 
        NSLog(@"animation finished!"); 
    }];
    
    //3. 较2,动画在该行代码执行后,延迟0.5s执行
    //   options: 动画时间曲线项,常用如下:
    //       UIViewAnimationOptionCurveEaseInOut            = 0 << 16, // default
    //       UIViewAnimationOptionCurveEaseIn               = 1 << 16,
    //       UIViewAnimationOptionCurveEaseOut              = 2 << 16,
    //       UIViewAnimationOptionCurveLinear               = 3 << 16,
    //       UIViewAnimationOptionAllowUserInteraction      = 1 <<  1, // turn on user interaction while animating
    //       UIViewAnimationOptionBeginFromCurrentState     = 1 <<  2, // start all views from current value, not initial value
    //       UIViewAnimationOptionRepeat                    = 1 <<  3, // repeat animation indefinitely
    //       UIViewAnimationOptionAutoreverse               = 1 <<  4, // if repeat, run animation back and forth
    [UIView animateWithDuration:0.5 delay:0.5 options:UIViewAnimationOptionCurveLinear animations:^{
       _field.alpha = 1.0;
    } completion:^(BOOL finished){ 
        NSLog(@"animation finished!"); 
    }];
    
    //4. 较3,动画附带一定的弹簧效果,IOS7+;
    //   usingSpringWithDamping: 阻尼率,0.0~1.0,越小振荡效果越明显
    //   initialSpringVelocity: 用于改变动画的初始速率,比如:_field.在X轴上 会以200pt/s 变化,而你想要的效果为100pt/s, 则可设置其值为0.5; 一般情况下,设置为0(即不做处理)较合适
    //   推荐使用该动画方法
    [UIView animateWithDuration:0.5 delay:0.5 usingSpringWithDamping:0.5 initialSpringVelocity:0.5 options:UIViewAnimationOptionCurveLinear animations:^{
    
    } completion:^(BOOL finished){ 
        NSLog(@"animation finished!"); 
    }];
    

    关键帧动画

    //较基础动画,可在一个动画中控制UIView的属性值发生多段变化。
    //   options: 动画时间曲线项,常用如下:
    //        UIViewKeyframeAnimationOptionCalculationModeLinear     = 0 << 10, // default
    //        UIViewKeyframeAnimationOptionCalculationModeDiscrete   = 1 << 10,
    //        UIViewKeyframeAnimationOptionCalculationModePaced      = 2 << 10,
    //        UIViewKeyframeAnimationOptionCalculationModeCubic      = 3 << 10,
    //        UIViewKeyframeAnimationOptionCalculationModeCubicPaced = 4 << 10,
    //        UIViewKeyframeAnimationOptionAllowUserInteraction      = UIViewAnimationOptionAllowUserInteraction, // turn on user interaction while animating
    //        UIViewKeyframeAnimationOptionBeginFromCurrentState     = UIViewAnimationOptionBeginFromCurrentState, // start all views from current value, not initial value
    //        UIViewKeyframeAnimationOptionRepeat                    = UIViewAnimationOptionRepeat, // repeat animation indefinitely
    //        UIViewKeyframeAnimationOptionAutoreverse               = UIViewAnimationOptionAutoreverse, // if repeat, run animation back and forth
    [UIView animateKeyframesWithDuration:0.5 delay:0.5 options:UIViewKeyframeAnimationOptionCalculationModeDiscrete animations:^{
       //关键帧1
       // addKeyframeWithRelativeStartTime: 相对起始时间
       // relativeDuration: 相对执行时间
       [UIView addKeyframeWithRelativeStartTime:0 relativeDuration:0.8 animations:^{
           _field.alpha = 1.0;
       }];
       //关键帧2
       [UIView addKeyframeWithRelativeStartTime:0.8 relativeDuration:0.2 animations:^{
           _field.alpha = 0.5;
       }];
    
    } completion:^(BOOL finished){
       NSLog(@"animation finished!");
    }];
    
  • 相关阅读:
    Binder核心原理解析
    写给 Android 应用工程师的 Binder 原理剖析
    Android Binder原理解析
    Android面试题(25)-Bundle机制_pgg_cold的博客-CSDN博客_android bundle机制
    腾讯Android面试精选题——谈一谈Binder的原理和实现一次拷贝的流程
    把这份关于Android Binder原理一系列笔记研究完,进大厂是个“加分项”...
    大型项目必备IPC之其他IPC方式(二)
    骚年!用Binder原理去彻底征服Android大厂面试官吧
    还不懂Binder的原理?那么你即将损失一张腾讯的offer
    每日一问 Binder
  • 原文地址:https://www.cnblogs.com/denjuy/p/4664592.html
Copyright © 2011-2022 走看看