//
// ViewController.m
// 005-核心动画-CAAnimationGroup
//
// Created by LTOVE on 15/10/15.
// Copyright (c) 2015年 LTOVE. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *imgView;
@end
@implementation ViewController
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// 有一张图片,同时可以有平移、旋转、缩放的效果
// 实现这个效果 使用组动画[CAAnimationGroup]
//组动画怎么使用
//1.创建对象
CAAnimationGroup *group = [CAAnimationGroup animation];
// 2 往里边添加多个动画
CABasicAnimation *position = [CABasicAnimation animation];
position.keyPath = @"position";
position.toValue = [NSValue valueWithCGPoint:CGPointMake(250, 250)];
CABasicAnimation *rotation = [CABasicAnimation animation];
rotation.keyPath = @"transform.rotation";
rotation.toValue = @(M_PI *4);
CABasicAnimation *scal = [CABasicAnimation animation];
scal.keyPath = @"transform.scale";
scal.toValue = @0.1;
group.duration = 4;
group.animations = @[position,rotation,scal];
[self.imgView.layer addAnimation:group forKey:nil];
}
@end
CAAnimationGroup-核心动画组
最新推荐文章于 2022-08-24 10:19:00 发布