iOS Core Animation: CALayer bringSublayerToFront?

前端 未结 8 1727
情深已故
情深已故 2020-12-25 12:28

How do I bring a CALayer sublayer to the front of all sublayers, analogous to -[UIView bringSubviewToFront]?

8条回答
  •  庸人自扰
    2020-12-25 12:36

    I'm curious why none of these answers mention the zPosition attribute on CALayer. Core Animation looks at this attribute to figure out layer rendering order. The higher the value, the closer it is to the front. These answers all work as long as your zPosition is 0, but to easily bring a layer to the front, set its zPosition value higher than all other sublayers.

提交回复
热议问题