CALayer - Place sublayer below storyboard UIButtons? CALayer - Place sublayer below storyboard UIButtons? ios ios

CALayer - Place sublayer below storyboard UIButtons?


The button layers are all sublayers of the main view's layers. You'll need to put your camera preview layer below the button's layers. Try this:

// put it behind all other subviews[self.view.layer insertSublayer:captureVideoPreviewLayer atIndex:0];// or, put it underneath your buttons, as long as you know which one is the lowest subview[self.view.layer insertSublayer:captureVideoPreviewLayer below:lowestButtonView.layer];


Just to add. You can raise any subclass of UIView up in the layer by calling UIView method bringSubviewToFront.

[self.view bringSubviewToFront:self.desiredButton];


matomo