gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 20:26:05 33 4
gpt4 key购买 nike

我有一个相当复杂的 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/

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