gpt4 book ai didi

ios - CATransform3DMakeRotation 在动画过程中隐藏了一半的 UIView

转载 作者:技术小花猫 更新时间:2023-10-29 10:43:17 32 4
gpt4 key购买 nike

使用以下带有 CATransform3DMakeRotation 的 UIView 动画,一半的 UIView 将在变换期间消失并在完成时重新出现。只有当界面构建器的 View 层次结构中的 UIView 后面有一个 UIImageView 时才会发生这种情况。

[UIView animateWithDuration:1.0 delay:0.0 options:nil animations:^{
myView.layer.transform = CATransform3DMakeRotation(M_PI,0.0,1.0,0.0);
} completion:nil];

下面是interface builder中的 View 布局

Interface Builder layout

下面是动画结果。

enter image description here

第二张图片是在任何动画发生之前,左半部分消失了。在它收缩然后长大超过中心点后,右侧(之前的左侧)重新出现,如第 4 幅图像所示。

当使用设置背景图片时

self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"jeans.png"]];

动画按预期完成。

最佳答案

郑重声明,答案在我的评论中

imageView.layer.zPosition = -400;

或者你可以做

myView.layer.zPosition = 400; // or some number greater than width/2

看起来旋转 View 的一部分被背景 View 遮挡了。由于它围绕其中心点旋转,它的一部分进入负 z 空间,因此在背景后面。

于是从

------- imageView
------- myView

     / myView
/
------- imageView
/
/

关于ios - CATransform3DMakeRotation 在动画过程中隐藏了一半的 UIView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13130250/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com