1

So I am currently adding a UIImageView on a UIView through self.addSubView(image), and I am also adding a cursor by adding a CAShapeLayer in the UIView's sublayer though self.layer.addSubLayer(cursor), but the UIImageView is rendered on top of the CAShapeLayer. How do I place CAShapeLayer on top of UIImageView?

Vince Gonzales
  • 855
  • 3
  • 20
  • 39
  • 2
    Play with the zPosition of your layer – GaétanZ Dec 10 '17 at 10:34
  • A `UIView` can have multiple layers. You are adding a `UIImageView` as a subview... You are then adding a "cursor" by adding a `CAShapeLayer`... however, no matter how many layers you add to the View, those layers will not be "on top of" the view's subview. What may solve your issue would be to add the Image as the content of a Layer of the View, instead of as a subview.. See this answer: https://stackoverflow.com/a/34603690/6257435 – DonMag Dec 10 '17 at 15:18

0 Answers0