组动画 CAAnimationGroup

来源:互联网 发布:java中多态的概念 编辑:程序博客网 时间:2024/05/16 23:50
////  ViewController.m//  组动画 CAAnimationGroup////  Created by 陆巧怡 on 15/7/31.//  Copyright (c) 2015年 Simon. All rights reserved.//#import "ViewController.h"@interface ViewController ()@property (strong, 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 *)touches withEvent:(UIEvent *)event{            //平移动画    CABasicAnimation *moveAnima = [CABasicAnimation animation];    moveAnima.keyPath = @"transform.translation.y";    moveAnima.toValue = @(100);        //缩放缩放    CABasicAnimation *scaleAnima = [CABasicAnimation animation];    scaleAnima.keyPath = @"transform.scale";    scaleAnima.toValue = @(0.0);        //旋转动画    CABasicAnimation *rotationAnima = [CABasicAnimation animation];    rotationAnima.keyPath = @"transform.rotation";    rotationAnima.toValue = @(M_PI_2);            //组动画    CAAnimationGroup *groupAnima = [CAAnimationGroup animation];    groupAnima.duration = 3.0;        groupAnima.animations = @[moveAnima,scaleAnima,rotationAnima];                [self.imageView.layer addAnimation:groupAnima forKey:nil];    }@end

0 0
原创粉丝点击