#pragma mark -
#pragma mark 图片旋转方法
- (void)createRotate {
UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, width(self.radarImageView.frame), height(self.radarImageView.frame))];
image.image = [UIImage imageNamed:@"updateScanning4"];
[self.radarRomationImageView addSubview:image];
UIImageView *image1 = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, width(self.radarImageView.frame), height(self.radarImageView.frame))];
image1.image = [UIImage imageNamed:@"updateScanning3"];
[self.radarRomationImageView addSubview:image1];
//添加动画
CABasicAnimation *monkeyAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
monkeyAnimation.toValue = [NSNumber numberWithFloat:2.0 *M_PI];
monkeyAnimation.duration = 1.5f;
monkeyAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
monkeyAnimation.cumulative = NO;
monkeyAnimation.removedOnCompletion = NO; //No Remove
monkeyAnimation.repeatCount = FLT_MAX;
[self.radarRomationImageView.layer addAnimation:monkeyAnimation forKey:@"AnimatedKey"];
[self.radarRomationImageView stopAnimating];
// 加载动画 但不播放动画
self.radarRomationImageView.layer.speed = 0.0;
}
- (void)playRomation {
NSArray *views = [self.radarRomationImageView subviews];
if (views.count > 1) {
[views[1] setHidden:NO];
}
self.radarImageView.image = [UIImage imageNamed:@"updateScanning2"];
self.radarRomationImageView.layer.speed = 0.6;
self.radarRomationImageView.layer.beginTime = 0.0;
CFTimeInterval pausedTime = [self.radarRomationImageView.layer timeOffset];
CFTimeInterval timeSincePause = [self.radarRomationImageView.layer convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime;
self.radarRomationImageView.layer.beginTime = timeSincePause;
}
图片的旋转动画
最新推荐文章于 2023-03-28 23:59:54 发布