博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
IOS 动画组
阅读量:6967 次
发布时间:2019-06-27

本文共 1561 字,大约阅读时间需要 5 分钟。

hot3.png

//

//  ViewController.m

//  动画组

//

//  Created by dc008 on 15/12/22.

//  Copyright © 2015 崔晓宇. All rights reserved.

//

#import "ViewController.h"

ViewController ()

@implementation ViewController

- (void)viewDidLoad {

    [super viewDidLoad];

   //初始化一个图层

    CALayer *_layer = [[CALayer alloc]init];

    _layer.frame = CGRectMake(20, 20, 40, 40);

    _layer.backgroundColor = [UIColor grayColor].CGColor;

    [self.view.layer addSublayer:_layer];

    

    //移动位置的动画

    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];

    animation.toValue = [NSValue valueWithCGPoint:CGPointMake(315, 607)];

    //z轴进行旋转

    CABasicAnimation *rotateAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];

    rotateAnimation.fromValue = [NSNumber numberWithFloat:0];

    rotateAnimation.toValue = [NSNumber numberWithFloat:6 * M_PI];//旋转3 一周的弧度是2*M_PI

    

    //layer放大

    CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];//.y.x

    scaleAnimation.fromValue = [NSNumber numberWithFloat:1.0];

    scaleAnimation.toValue = [NSNumber numberWithFloat:3.0];

    

    //把上面的动画组合起来

    CAAnimationGroup *groupAnimation = [CAAnimationGroup animation];//动画组初始化

    groupAnimation.autoreverses = YES;

    groupAnimation.repeatCount = HUGE_VALF;

    groupAnimation.duration = 3.0;

    groupAnimation.animations = @[animation,rotateAnimation,scaleAnimation];

    [_layer addAnimation:groupAnimation forKey:@"layerMove"];

}

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

@end

转载于:https://my.oschina.net/u/2499773/blog/549403

你可能感兴趣的文章
repmgr 4.3 发布,PostgreSQL 复制与故障转移管理工具
查看>>
十年再出发:阿里云智能战略加速的“四级火箭” ...
查看>>
阿里云RPA(机器人流程自动化)干货系列之六:客户端安装及激活 ...
查看>>
Alibaba Cluster Data 开放下载:270 GB 数据揭秘你不知道的阿里巴巴数据中心 ...
查看>>
Decision Tree
查看>>
四万高手过招,这份阿里全球数学竞赛试题你真的不要看吗 ...
查看>>
进行移动端Unity开发,针对引擎PowerVR性能建议
查看>>
linux gcc Makefile
查看>>
SpringBoot-Security-用户权限分配-配置验证规则
查看>>
学习大数据要掌握哪些语言?需要学习哪些内容? ...
查看>>
2019阿里云峰会-边缘计算专场,邀您共话大连接低时延场景下的技术探索与实践 ...
查看>>
云栖专辑| 阿里毕玄:程序员的成长路线
查看>>
jvm知识点总览
查看>>
如何在Windows 10 / 8.1 / 8中安装PHP或XAMP
查看>>
地铁译:Spark for python developers ---Spark的数据戏法
查看>>
举个栗子:专有云MaxCompute创建TableStore外部表
查看>>
网站服务器设置禁PING的方法步骤
查看>>
Linux基础命令---lpstat查看打印机状态
查看>>
新年福利 | 架构的“一小步”,业务的一大步
查看>>
Confluence 6 升级中的一些常见问题
查看>>