Layer.zPosition does not work with non-sister UIViews

I have a fairly complicated UIImageViews hierarchy . Initially, I carefully changed the order of the brothers when one UIImageViewmoved in front of the other. Then I found out about myUIImageView.layer.zPositionand switched to it. Worked a lot easier. It works almost all the time. I learned from this SO question what zPositionworks only between brother layers. Big! Therefore, I have two questions: are there any factual documents about this? and is there some kind of fiction I can use to make this work? (e.g. add all my UIImageViews to UIView that are never visible). thanks in advance.

+1
source share
1 answer

From the title of your question, I wonder if you understand that the property zPositionworks with the word, not nets. To cope with the depth of each image that has a property zPosition, you will need to have all the images as layers for the same UIView object. The property is zPositiondocumented in Apple 's Core Animation Programming Guide :

The zPosition property indicates the component of the z axis at the position of the layer. ZPosition is designed to set the visual position of a layer relative to its related layers. It should not be used to indicate the order of the brothers brothers, instead reorder the layer in the sublevel array.

+5
source

Source: https://habr.com/ru/post/1760887/


All Articles