iOS UIView 动画 CATransform3DMakeRotation 混淆 [英] iOS UIView Animation CATransform3DMakeRotation confusion

查看:22
本文介绍了iOS UIView 动画 CATransform3DMakeRotation 混淆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UIView,我正在尝试动画向下翻转,同时将其轴放在视图的底部.例如:

I have a UIView that I am trying to animate flipping down, while having its axis at the bottom of the view. E.g.:

为此,我尝试使用 UIView 动画:

To do this, I am trying to use a UIView animation:

[UIView animateWithDuration:3 delay:0 options:UIViewAnimationCurveEaseOut animations:^{

     // Flip Down
     top3.layer.anchorPoint = CGPointMake(0.5, 1.0);
     top3.layer.transform = CATransform3DMakeRotation(M_PI, 1, 0, 0);

 } completion:^(BOOL finished) {

     // Reset?
     //top3.transform = CGAffineTransformMakeScale(1, 1);

 }];

现在它不能像我想要的那样工作,似乎视图正在远离用户而不是朝向用户进行动画处理.它似乎没有提供 3D 效果,使其在向下旋转时看起来更接近用户,如我的图像所示.我很肯定这是因为我对如何使用 CATransform3DMakeRotation 缺乏了解.

Right now it isn't working how I want, it seems like the view is animating AWAY from the user rather then toward. It does't seem to give a 3D effect that makes it look closer to the user when rotating down, as shown in my image. I am positive that this is because of my lack of understanding how to use CATransform3DMakeRotation.

问题:

  • 如何让视图在下降时看起来更接近用户?例如在我的图像示例中倾斜它?
  • 当我设置我的 anchorPoint 时,它会将我的视图向下移动,我该如何防止这种情况并仍然设置我的 anchorPoint?
  • 使用 UIView 动画,我可以使用缓动设置吗? 在选项中使用 UIViewAnimationCurveEaseOut.
  • 我可以使用重力设置吗?
  • How can I make the view appear closer to the user as it drops? Such as skewing it as in my image example?
  • When I set my anchorPoint it shifts my view down, how can I prevent this and still set my anchorPoint?
  • With UIView animation, can I use easing settings? Used UIViewAnimationCurveEaseOut in options.
  • Can I use gravity settings?

推荐答案

  • 您的问题并不完全清楚,但听起来您在动画过程中没有看到透视失真 - 视图在旋转时保持矩形,对吗?要使 CALayer 以透视图显示,其 transform 需要设置 m34 元素,如此处.
  • 为了补偿 anchorPoint 移动你的视图层,你需要改变视图的原始位置.
  • 是的.除了您正在使用的动画选项之外,还有几个动画选项,您可以像这样组合它们(例如): UIViewAnimationOptionBeginFromCurrentState |UIViewAnimationOptionCurveEaseInOut |UIViewAnimationOptionAllowUserInteraction.
  • Core Animation 并没有真正的物理概念.根据您想要的效果,您可以通过将多个动画与特定的缓动设置链接在一起来实现它——例如,撞击固体表面的下落物体将在其下降过程中使用缓入"动画,然后使用缓入"动画如果它随后反弹,则缓出".
    • It’s not completely clear from your question, but it sounds like you’re not seeing a perspective distortion during the animation—the view’s staying rectangular as it rotates, right? For a CALayer to display with perspective, its transform needs to have the m34 element set, as described here.
    • To compensate for the anchorPoint moving your view’s layer, you need to change the view’s original position.
    • Yes. There are several animation options in addition to the one you’re using, and you can combine them like this (for example): UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction.
    • Core Animation doesn’t really have any concept of physics. Depending on the effect you’re going for, you can achieve it by chaining multiple animations together with particular easing settings—for instance, a falling object that hits a solid surface would use an "ease in" animation on its way down, then an "ease out" if it then bounced back up.
    • 这篇关于iOS UIView 动画 CATransform3DMakeRotation 混淆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆