zoukankan      html  css  js  c++  java
  • 核心动画 (CAAnimationGroup)

    Main.storyboard

    ViewController.m

    //

    //  ViewController.m

    //  8A05.核心动画 CAAnimationGroup

    //

    //  Created by huan on 16/2/5.

    //  Copyright © 2016 huanxi. All rights reserved.

    //

     

    #import "ViewController.h"

     

    @interface ViewController ()

    @property (weak, nonatomic) IBOutlet UIImageView *imageView;

     

    @end

     

    @implementation ViewController

     

    - (void)viewDidLoad {

        [super viewDidLoad];

        // Do any additional setup after loading the view, typically from a nib.

        

        

    }

     

    -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

        //有一张图片,同时可以平移、旋转、缩放的效果

        //实现这个效果 使用组动画【CAAnimatonGroup

        //组动画怎么使用

        

        //1.创建对象

        CAAnimationGroup *group = [CAAnimationGroup animation];

        

        //2.往里面添加多个动画

        //2.1 平移动画

        CABasicAnimation *positionAni = [CABasicAnimation animation];

        positionAni.keyPath = @"position";

        positionAni.toValue = [NSValue valueWithCGPoint:CGPointMake(250, 250)];

        //2.2 旋转动画

        CABasicAnimation *rotationAni = [CABasicAnimation animation];

        rotationAni.keyPath = @"transform.rotation";

        rotationAni.toValue = @(M_PI_2);

        

        //2.3 缩放的效果

        CABasicAnimation *scaleAni = [CABasicAnimation animation];

        scaleAni.keyPath = @"transform.scale";

        scaleAni.toValue = @(0.5);

        

        group.duration = 3;

        group.animations = @[positionAni, rotationAni, scaleAni];

        //3.把组动画添加到图层上

        [self.imageView.layer addAnimation:group forKey:nil];

    }

    @end

  • 相关阅读:
    1.8 在select语句使用条件逻辑
    用做网页开发经历了三个阶段(附长篇讨论) good
    unigui数据库连接池
    idhttp.post方式 调用datasnap rest 远程方法
    IdHttpServer实现webservice
    DATASNAP REST WEBSERVICES中间件如何跨平台使用
    Cracking the Coding Interview
    分享基于Entity Framework的Repository模式设计(附源码)
    建造者模式
    7z文件格式及其源码
  • 原文地址:https://www.cnblogs.com/Lu2015-10-03/p/5191343.html
Copyright © 2011-2022 走看看