zoukankan      html  css  js  c++  java
  • 0125——动画2

       //显隐
        CABasicAnimation *capacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
        capacityAnimation.fromValue = @1;
        capacityAnimation.toValue = @0;
        
        //放大缩小
        CABasicAnimation   *scaleAniamation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
        scaleAniamation.fromValue = @0.5;
        scaleAniamation.toValue = @1.5;
           
        //移动
        CABasicAnimation *moveAnimation = [CABasicAnimation animationWithKeyPath:@"position"];
        moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(200, 200)];
        
        //旋转
        CABasicAnimation *rotateAniamation = [CABasicAnimation animationWithKeyPath:@"transform"];
        rotateAniamation.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
        rotateAniamation.toValue = [NSValue valueWithCATransform3D:CATransform3DRotate(_layer.transform, M_PI, 0.3, 0.5, 1)];
        

    //添加动画
        [CATransaction setAnimationDuration:1.0];//动画速度
        [_layer addAnimation:capacityAnimation forKey:nil];
        [_layer addAnimation:scaleAniamation forKey:nil];
        [_layer addAnimation:moveAnimation forKey:nil];
        [_layer addAnimation:rotateAniamation forKey:nil];

    //组动画  
        CAAnimationGroup *group = [CAAnimationGroup animation];
        group.duration = 1;
        group.removedOnCompletion   = NO;
        group.fillMode = kCAFillModeForwards;
        group.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
        
        group.animations = @[capacityAnimation,scaleAniamation,moveAnimation,rotateAniamation];
        
        [_layer addAnimation:group forKey:nil];

    还有更多细节和Core Animation的高级应用:https://zsisme.gitbooks.io/ios-/content/chapter1/the-layer-tree.html

  • 相关阅读:
    Python学习(3)——if语句
    Python学习(2)——编码
    一次性邮箱
    Python学习(1)
    Hello World
    java设计模式创建篇------原型模式
    Java技巧------Cloneable接口与clone方法
    java设计模式创建篇------抽象工厂
    java设计模式创建篇------工厂模式
    python函数式编程
  • 原文地址:https://www.cnblogs.com/damonWq/p/5158430.html
Copyright © 2011-2022 走看看