【发布时间】:2014-04-04 22:52:09
【问题描述】:
我正在使用CABasicAnimation 连续旋转UIImageView,我希望能够获得旋转角度。
-(void)viewDidAppear:(BOOL)animated{
[self spinAnimationOnView:self.myImageView
duration:2
repeat:HUGE_VAL];
}
- (void)spinAnimationOnView:(UIView*)view duration:(CGFloat)duration repeat:(float)repeat{
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0];
rotationAnimation.duration = duration;
rotationAnimation.repeatCount = repeat;
[view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}
动画按预期运行。但后来我尝试得到这样的旋转角度:
CGFloat angle = [(NSNumber *)[self.myImageView valueForKeyPath:@"layer.transform.rotation.z"] floatValue];
NSLog(@"ROTATION = %f", angle);
输出始终为 0。有什么想法吗?
【问题讨论】:
标签: ios objective-c rotation cabasicanimation