CABasicAnimation 动画

来源:互联网 发布:使用nginx做负载均衡 编辑:程序博客网 时间:2024/04/29 23:08

1、顺时针旋转

CABasicAnimation *spinAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];

    spinAnimation.byValue = [NSNumber numberWithFloat:2*M_PI];
    spinAnimation.duration = self.animationDuration;
    spinAnimation.delegate = self;

    [self.layer addAnimation:spinAnimation forKey:@"spinAnimation"];


2、逆时针旋转


 CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];
 animation.delegate = self;
 animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI , 0, 0, 1.0)];
 animation.duration = 30;
 animation.cumulative = YES;
 animation.repeatCount = INT_MAX;
 
 [iv.layer addAnimation:animation forKey:@"animation"];

原创粉丝点击