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

iOS组动画,

时间:2015-01-15 23:34:53      阅读:290      评论:0      收藏:0      [点我收藏+]

标签:

#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

 

iOS组动画,

标签:

原文地址:http://www.cnblogs.com/canghaige/p/4227400.html

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