核心动画05-CAAnimationGroup

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    //1、创建旋转动画对象
    CABasicAnimation *rotate = [CABasicAnimation animation];
    rotate.keyPath = @"transform.rotation";
    rotate.toValue = @(M_PI);
    
    //2、创建缩放动画对象
    CABasicAnimation *scale = [CABasicAnimation animation];
    scale.keyPath = @"transform.scale";
    scale.toValue = @(0.0);
    
    //3、创建平移动画
    CABasicAnimation *move = [CABasicAnimation animation];
    move.keyPath = @"transform.translation";
    move.toValue = [NSValue valueWithCGPoint:CGPointMake(100, 100)];
    
    //4、将所有的动画添加到动画组中
    CAAnimationGroup *group = [CAAnimationGroup animation];
    group.animations = @[rotate,scale,move]; //次序无关,这几个动画同时执行
    
      //这些属性不再是添加到单个的动画上面,而是添加到整个的动画组上面
    group.duration = 2.0;
    group.removedOnCompletion = NO;
    group.fillMode = kCAFillModeForwards;
    
    [self.myview.layer addAnimation:group forKey:nil];
}

 

posted on 2015-05-15 13:15  快乐加油站789  阅读(140)  评论(0编辑  收藏  举报

导航