iOS develops CAAnimation to do rotation animation

UIImageView do rotation animation

insert image description here
Add rotation animation to layer using CABasicAnimationforUIViewlayer

/// 开始旋转
- (void)showDownloadingImageView {
    
    
    CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    rotationAnimation.fromValue = [NSNumber numberWithFloat:0.f];
    rotationAnimation.toValue = [NSNumber numberWithFloat:M_PI * 2.0];
    rotationAnimation.duration = 1;
    rotationAnimation.cumulative = YES;
    rotationAnimation.repeatCount = NSUIntegerMax;
    rotationAnimation.autoreverses = NO;
    [self.loadingView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}

/// 停止旋转
- (void)hideDownloadingImageView {
    
    
    [self.loadingView.layer removeAllAnimations];
}

Guess you like

Origin blog.csdn.net/weixin_46926959/article/details/129327064