我正在尝试找到一种方法来为 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/