即時通訊尋求旋轉一個UIImageView,我發現了一些有益的代碼IOS需要旋轉圖像,並保持它在那裏,動畫
- (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"];
}
的問題是,圖像翻轉回來時,在動畫完成,即時通訊希望旋轉它並保持在那裏。我需要翻轉實際圖像還是可以翻轉ImageView?而我將如何做到這一點?
這應該這樣做'rotationAnimation.removedOnCompletion = NO;' – BooRanger
不起作用,仍然翻轉 –
您可以使用' dispatch_after'塊並將'view.transform.rotation.z'分發到所需的值。有點黑客,但它應該工作。 – Majster