1 // 2 // ViewController.m 3 // CAAnimationGroup 4 // 5 // Created by ys on 15/11/22. 6 // Copyright (c) 2015年 ys. All rights reserved. 7 // 8 9 #import "ViewController.h"10 11 @interface ViewController ()12 @property (weak, nonatomic) IBOutlet UIView *redView;13 14 @end15 16 @implementation ViewController17 18 - (void)viewDidLoad {19 [super viewDidLoad];20 }21 22 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event23 {24 //创建旋转动画对象25 CABasicAnimation *rotate = [CABasicAnimation animation];26 rotate.keyPath = @"transform.rotation";27 rotate.toValue = @(M_PI_2);28 //创建缩放动画对象29 CABasicAnimation *scale = [CABasicAnimation animation];30 scale.keyPath = @"transform.scale";31 scale.toValue = @(0.0);32 //创建平移动画对象33 CABasicAnimation *move = [CABasicAnimation animation];34 move.keyPath = @"transform.translation";35 move.toValue = [NSValue valueWithCGPoint:CGPointMake(200, 200)];36 //创建动画对象组37 CAAnimationGroup *group = [CAAnimationGroup animation];38 group.animations = @[rotate,scale,move];39 group.duration = 11.5;40 group.removedOnCompletion = NO;41 group.fillMode = kCAFillModeForwards;42 43 [self.redView.layer addAnimation:group forKey:nil];44 45 }46 47 @end