ios - 动画 View - 旋转、缩小并移出屏幕

标签 ios xcode uianimation

我有一个自定义 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/

相关文章:

ios - 如何在 Collection View 中给 UILabel 一个闪烁的效果

iphone - UIImagePickerController 语言未更改

ios - 为什么 `transform.rotation` 可用于 CoreAnimation,但无法使用 getter 访问?

objective-c - 在 iOS6 中的单个 UIViewController 上禁用自动旋转

ios - Storyboard忽略 UIInterfaceOrientation 设置

ios - 类似于 iOS 中的 Apple Maps 应用程序的底部动画

ios - 带解析的查询太慢

ios - Swift 线程安全计数器变量?用于跟踪何时删除网络事件指示器

objective-c - SDK/框架包含在 xCode 项目中时如何工作?

ios - 调整 UIView 大小时动画无法按预期工作