iphone - UIView逼真的3d旋转动画

标签 iphone ios objective-c xcode core-animation

我正在尝试找到一种方法来为 UIView 的 3D 旋转设置动画。如果您选择“横幅”样式,我希望它看起来像推送通知的动画。我正在尝试使用类似

CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform"];
CATransform3D t = CATransform3DIdentity;
t = CATransform3DTranslate(t, 0, -self.bounds.size.height/2, 0);
t = CATransform3DRotate(t, M_PI_2, 1, 0, 0);
t = CATransform3DTranslate(t, 0, -self.bounds.size.height/2, 0);
[anim setFromValue:[NSValue valueWithCATransform3D:CATransform3DIdentity]];
[anim setToValue:[NSValue valueWithCATransform3D:t]];
anim.removedOnCompletion = NO;
[anim setDuration:0.25];
anim.fillMode = kCAFillModeForwards;
anim.delegate = self;
[self.layer addAnimation:anim forKey:@"Rotation"];

但这看起来很平坦,不像推送通知的横幅那样逼真 3D。我怎样才能让这个动画更逼真?

最佳答案

您可能想深入了解如何 CMNavBarNotificationView已实现。

另外,有不同类型的 CALayer,您可能希望从动画 View 的 +(Class)layerClass 中选择一个所需的类型。在我看来,您坚持使用普通 CALayer。

关于iphone - UIView逼真的3d旋转动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15130085/

相关文章:

iphone - 具有半透明选定背景的 UITableViewCell

ios - Healthkit - 权利文件和 plist 文件

objective-c - 在 iOS 中处理 JSON 输出

objective-c - iOS无法播放我的声音?

iphone - UIFont 类别的单元测试用例编写问题

ios - 支付整合 payzee vs stripe

ios - xcode 8 中的 btnactionsender 而不是 btnaction

ios - 如何在 swift 3 中从字符串中获取日期?

ios - 身份验证过程后存储用户对象的最佳做法

iphone - 我如何在导航 Controller 中弹出