iphone - layer.zPosition 不适用于非同级 UIView

标签 iphone graphics uiimageview quartz-graphics layer

我有一个相当复杂的 UIImageView 层次结构。最初,当一个 UIImageView 移动到另一个 UIImageView 前面时,我小心地交换了同级顺序。然后我发现了 myUIImageView.layer.zPosition 并改用它。解决起来简单多了。它甚至几乎一直有效。我从this SO question得知zPosition 仅适用于同级层。伟大的!所以我真的有两个问题:是否有关于此的实际文档?而且,我可以用某种软糖来让它发挥作用吗? (就像将我所有的 UIImageView 添加到一个永远不可见的 UIView 中一样)。提前谢谢。

最佳答案

从问题的标题来看,我想知道您是否理解 zPosition 属性适用于同级图层,而不是同级 View 。要使用 zPosition 属性处理每个图像的深度,您需要将所有图像作为同级图层放在一个 UIView 对象中。 zPosition 属性记录在 Apple 的 Core Animation Programming Guide 中。 :

The zPosition property specifies the z-axis component of the layer's position. The zPosition is intended to be used to set the visual position of the layer relative to its sibling layers. It should not be used to specify the order of layer siblings, instead reorder the layer in the sublayer array.

关于iphone - layer.zPosition 不适用于非同级 UIView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5466116/

相关文章:

iphone - 如何判断对象是否在 NSArray 中?

algorithm - 如何从汉字中提取笔划

ios - 如何在 UIImageView 上创建从一个图像到另一个图像的淡入淡出效果?

ios - swift iOS : How do I make an Instagram link?

ios - UIImageView和UITapGestureRecognizer在swift中的交互

iphone - 来自图像的自定义 UIToolBar

iphone - Interface Builder(iPhone dev)自定义按钮背景图像不考虑拉伸(stretch)设置

Java 闪烁图形

c++ - 如何访问位图中的像素颜色?

javascript - 如何创建可检测浏览器类型并进行相应重定向的 Google 协作平台脚本?