CATransform3D旋转导致图像的一半消失 [英] CATransform3D rotate causes half of image to disappear
本文介绍了CATransform3D旋转导致图像的一半消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下代码旋转图像,但是已经旋转出页面的图像的一半(沿着y轴)消失了。怎么修? 标题
以弧度为单位。
I'm using the following code to rotate an image, but half the image (down the y-axis) that has been rotated "out of" the page, disappears. How to fix? heading
is in radians.
CALayer *layer = myUIImageView.layer;
CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
rotationAndPerspectiveTransform.m34 = 1.0 / 500;
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, heading, 0.0f, 1.0f, 0.0f);
layer.transform = rotationAndPerspectiveTransform;
推荐答案
解决方法是设置 zPosition
适当的所有图层的属性。感谢@Brad Larson,他在此处的评论中提出了此解决方案。看来,当你开始使用 CATransform3D
时,由addsubview建立的普通zindex视图层次结构将被抛出窗口。
The solution to this was to set the zPosition
property of all my layers appropriately. Thanks is due to @Brad Larson, who suggested this solution in a comment here. It seems that, when you start using CATransform3D
, the normal zindex view hierarchy established by addsubview is thrown out the window.
这篇关于CATransform3D旋转导致图像的一半消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文