0
我有一個自定義的UIView類,我想旋轉,縮小和移動屏幕在同一時間的任意角度。動畫視圖 - 旋轉,縮小和移動屏幕
我有這樣的代碼,將幾次
- (void)spinLayer:(CALayer *)inLayer duration:(CFTimeInterval)inDuration currentAngle:(CGFloat)curAngle
direction:(int)direction
{
CABasicAnimation* rotationAnimation;
// Rotate about the z axis
rotationAnimation =
[CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
// Rotate 360 degress, in direction specified
rotationAnimation.toValue = [NSNumber numberWithFloat:(M_PI * 4 * direction) + curAngle];
// Perform the rotation over this many seconds
rotationAnimation.duration = inDuration;
// Set the pacing of the animation
rotationAnimation.timingFunction =
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
// Add animation to the layer and make it so
[inLayer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}
我稱之爲像這樣旋轉層:
CGFloat angle = atan2(sender.transform.b, sender.transform.a); // Current angle
[self spinLayer:sender.layer duration:0.5 currentAngle:angle direction:1]; //direction can be -1
但我怎麼能現在縮小視圖,並在同一移動它時間?
由於
對不起,我想我在編輯我的問題的同時你必須回答。我現在輪換工作正常,我只需要休息。 – Darren
我會使用一個更復雜的動畫類,允許您爲動畫設置多個值。 – FelixLam
你會如何旋轉更復雜的課程?閱讀這個問題http://stackoverflow.com/questions/518530/rotate-a-uiview-around-its-center-but-several-times建議我使用的方法。 – Darren