Bringing a view forward or back programmatically is a common task for iOS developers.
To bring a view forward in Swift, call bringSubviewToFront
:
view.bringSubviewToFront(childView)
You can also use the superView
property to call this from the child view:
childView.superview?.bringSubviewToFront(childView)
To bring a send backward in Swift, call sendSubviewToBack
:
view.sendSubviewToBack(childView)
Again, you can use the superView
property to call this from the childview:
childView.superview?.sendSubviewToBack(childView)
The Complete iOS App Development Bootcamp
Disclosure: This website may contain affiliate links, meaning when you click the links and make a purchase, we receive a commission.