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

  • 相关阅读:
    C# switch-case
    Python学习日记之中文支持
    C++学习笔记(一)之指针
    python CGI 编程实践
    linux 配置 python3 CGI
    PowerShell入门简介
    资源整合,总有你想要的
    python 爬虫之 urllib库
    一天学一个Linux命令:第一天 ls
    DG磁盘分区提示错误
  • 原文地址:https://www.cnblogs.com/damonWq/p/5158430.html
Copyright © 2011-2022 走看看