我有一个自定义 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
但是我现在如何才能同时缩小 View 并移动它呢?
谢谢
最佳答案
将 View 旋转 360 度不会产生动画,因为开始和结束状态相同。您应该尝试使用多个值作为旋转值。
关于ios - 动画 View - 旋转、缩小并移出屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10916684/