iOS组动画,

#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

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。