码迷,mamicode.com
首页 > 其他好文 > 详细

CAAnimationGroup简单实用

时间:2014-10-21 11:57:15      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:io   ar   for   sp   2014   on   ad   bs   ef   

//
//  MJViewController.m
//  09-核心动画05-CAAnimationGroup
//
//  Created by apple on 14-4-21.
//  Copyright (c) 2014年 itcast. All rights reserved.
//

#import "MJViewController.h"

@interface MJViewController ()
@property (weak, nonatomic) IBOutlet UIView *myvie;

@end

@implementation MJViewController

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    // 1.创建旋转动画对象
    CABasicAnimation *rotate = [CABasicAnimation animation];
    rotate.keyPath = @"transform.rotation";
    rotate.toValue = @(M_PI);
    
    // 2.创建缩放动画对象
    CABasicAnimation *scale = [CABasicAnimation animation];
    scale.keyPath = @"transform.scale";
    scale.toValue = @(0.0);
    
    // 3.平移动画
    CABasicAnimation *move = [CABasicAnimation animation];
    move.keyPath = @"transform.translation";
    move.toValue = [NSValue valueWithCGPoint:CGPointMake(100, 100)];
    
    // 4.将所有的动画添加到动画组中
    CAAnimationGroup *group = [CAAnimationGroup animation];
    group.animations = @[rotate, scale, move];
    group.duration = 2.0;
    group.removedOnCompletion = NO;
    group.fillMode = kCAFillModeForwards;
    
    [self.myvie.layer addAnimation:group forKey:nil];
}

@end

CAAnimationGroup简单实用

标签:io   ar   for   sp   2014   on   ad   bs   ef   

原文地址:http://www.cnblogs.com/xiaokanfengyu/p/4039611.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!