360 旋转

- (void)rotateSpinningView

{

    [UIView animateWithDuration:1.5 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{

        self.imageView.transform = CGAffineTransformRotate(self.imageView.transform, M_PI);

    } completion:^(BOOL finished) {

        [self rotateSpinningView];

    }];

}

 

- (void) runSpinAnimationOnView:(UIView*)view duration:(CGFloat)duration rotations:(CGFloat)rotations repeat:(float)repeat;

{

    CABasicAnimation* rotationAnimation;

    rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];

    rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 /* full rotation*/ * rotations * duration ];

    rotationAnimation.duration = duration;

    rotationAnimation.cumulative = YES;

    rotationAnimation.repeatCount = repeat;

    

    [view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];

}

posted on 2015-12-30 21:04  Jenaral  阅读(206)  评论(0编辑  收藏  举报

导航