UIImageView做旋转动画
使用CABasicAnimation
为UIView
的layer
层添加旋转动画
/// 开始旋转
- (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];
}