您的位置:首页 > 移动开发 > IOS开发

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

2015-09-06 17:33 501 查看
****动画组

// 核心动画都是假象,不能改变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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: