iOS UIView 动画 CATransform3DMakeRotation 混淆
我有一个 UIView,我正在尝试将其向下翻转,同时将其轴置于视图底部。例如:
为此,我尝试使用 UIView 动画:
[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 。
问题:
- 如何让视图在下降时看起来更靠近用户?比如像我的图像示例中那样倾斜它?
- 当我设置
anchorPoint
时,它会将我的视图向下移动,如何防止这种情况发生并仍然设置我的anchorPoint
? 对于在选项中使用了UIView
动画,我可以使用缓动设置吗?UIViewAnimationCurveEaseOut
。- 我可以使用重力设置吗?
I have a UIView
that I am trying to animate flipping down, while having its axis at the bottom of the view. E.g.:
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);
}];
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
.
Questions:
- 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
? WithUsedUIView
animation, can I use easing settings?UIViewAnimationCurveEaseOut
in options.- Can I use gravity settings?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
transform
需要具有m34
元素集,如 此处。anchorPoint
移动视图图层,您需要更改视图的原始位置。transform
needs to have them34
element set, as described here.anchorPoint
moving your view’s layer, you need to change the view’s original position.UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction
.