码迷,mamicode.com
首页 > 移动开发 > 详细

IOS第18天(9,核心动画-动画组)

时间:2015-09-06 19:57:15      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:

****动画组

// 核心动画都是假象,不能改变layer的真实属性的值
// 展示的位置和实际的位置不同。实际位置永远在最开始位置

#import "HMViewController.h"

@interface HMViewController ()
@property (weak, nonatomic) IBOutlet UIView *redView;

@end

@implementation HMViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}



- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    
    CABasicAnimation *rotation = [CABasicAnimation animation];
    
    rotation.keyPath = @"transform.rotation";
    
    rotation.toValue = @M_PI_2;
    
    CABasicAnimation *position = [CABasicAnimation animation];
    
    position.keyPath = @"position";
    
    position.toValue = [NSValue valueWithCGPoint:CGPointMake(100, 250)];
    CABasicAnimation *scale = [CABasicAnimation animation];
    scale.keyPath = @"transform.scale";
    scale.toValue = @0.5;
    CAAnimationGroup *group = [CAAnimationGroup animation];
    
    group.animations = @[rotation,position,scale];
    
    group.duration = 2;
    
    // 取消反弹
    group.removedOnCompletion = NO;
    group.fillMode = kCAFillModeForwards;
    
    
    [_redView.layer addAnimation:group forKey:nil];
}

@end

 

IOS第18天(9,核心动画-动画组)

标签:

原文地址:http://www.cnblogs.com/ios-g/p/4786737.html

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