layer.zPosition does not work with non-sibling UIViews

前端 未结 1 1941
没有蜡笔的小新
没有蜡笔的小新 2020-12-21 17:02

I have a reasonably complex hierarchy of UIImageViews. Originally, I was carefully swapping the sibling order when one UIImageView moved in front

相关标签:
1条回答
  • 2020-12-21 17:25

    From the title of your question, I wonder if you understand that the zPosition property works with sibling layers, not sibling views. To deal with the depth of every image you have with the zPosition property, you will need to have all the images as sibling layers within one single UIView object. The zPosition property is documented in Apple's 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.

    0 讨论(0)
提交回复
热议问题