标签:
#ViewController.m
#import "ViewController.h"
@interface ViewController ()
/**
* storybord连线
*/
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touchesBegan");
self.view.userInteractionEnabled = NO;
//创建旋转动画对象
CABasicAnimation *rotate = [CABasicAnimation animation];
rotate.keyPath = @"transform.rotation";
rotate.toValue = @(M_PI * 10);
//创建缩放动画对象
CABasicAnimation *scale = [CABasicAnimation animation];
scale.keyPath = @"transform.scale";
scale.toValue = @(0.0);
//创建平移动画对象
CABasicAnimation *translation = [CABasicAnimation animation];
translation.keyPath = @"transform.translation";
translation.toValue = [NSValue valueWithCGPoint:CGPointMake(300, 500)];
//将所有动画添加到组中
CAAnimationGroup *group = [CAAnimationGroup animation];
group.animations = @[rotate, scale, translation];
group.duration = 10;
group.delegate = self;
// group.removedOnCompletion = NO;
// group.fillMode = kCAFillModeForwards;
[self.imageView.layer addAnimation:group forKey:nil];
}
#pragma mark - 动画开始
-(void)animationDidStart:(CAAnimation *)anim
{
NSLog(@"animationDidStart");
}
#pragma mark - 动画结束
-(void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
self.view.userInteractionEnabled = YES;
NSLog(@"animationDidStop");
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touchesEnded");
}
@end
标签:
原文地址:http://www.cnblogs.com/canghaige/p/4227400.html