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 !
Your implementation of this method can do any of the following: - Adjust the size and position of any immediate subviews. - Add or remove subviews or Core Animation layers. - Force a subview to be redrawn by calling its setNeedsDisplay or setNeedsDisplayInRect: method.
Working with UIViews happens on the main thread, it means it is using CPU power. CALayer: Layers on other hand have simpler hierarchy. That means they are faster to resolve and quicker to draw on the screen. There is no responder chain overhead unlike with views.
All UIView subclasses have a layer property, which is responsible for drawing their contents efficiently. These layers are powered by Core Animation, which handles all the drawing and animation that UIKit requests.
An object that manages image-based content and allows you to perform animations on that content.
In Swift:
self.view.layer.insertSublayer(self.avPlayerLayer, below: self.button1.layer)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With