Reputation: 2574
I got a UIView
(let's call it superview) which contains another UIView
(lets call it subview).
I'd like to add a CALayer
so that it is visible on top of my superview, but under my subview.
In other words, my subview's background should override the layer.
I've had a look at addLayer:below:
and others, but I'm not sure how to use it.
Thanks.
EDIT: My bad, I had another view between superview and subview, and I was messing with it. Thanks guys !
Upvotes: 13
Views: 22009
Reputation: 24205
A more general solution where you don't have access to the subviews:
layer.insertSublayer(sublayer, at: 0)
Upvotes: 5
Reputation: 15694
In Swift:
self.view.layer.insertSublayer(self.avPlayerLayer, below: self.button1.layer)
Upvotes: 11
Reputation: 603
[self.view.layer insertSublayer:CALayer below:subview.layer]
Upvotes: 31