首页 > 移动平台 > 详细

iOS组动画,

时间:2015-01-15 23:32:18      阅读:312      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!