本文介绍了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
。
二手 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 myanchorPoint
? - Used
UIViewAnimationCurveEaseOut
in options. - Can I use gravity settings?
推荐答案
- 这不是从你的问题完全清楚,但它听起来像你不是动画视图的矩形停留期间,看到了透视变形,因为它旋转,对不对?对于一个CALayer的显示与角度,其
转换
需要有M34
元素集合,如here. - 要补偿
anchorPoint
移动视图的图层,您需要更改视图的原始位置。 - 是。还有,除了你使用的是几种不同的动画选项,你可以将它们像这样(例如):
UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction
。 - 在核心动画并没有真正有物理的任何概念。根据你要的效果,可以通过链接多个动画一起特别宽松的设置 - 例如,击中一个固体表面可以用缓解动画的道路上下来一个下落的物体,那么实现它缓出,如果它再反弹起来。
- 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 them34
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混乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!