How to send a UIView element backwards in Swift
From apple documentation:
bringSubviewToFront(_:)
sendSubviewToBack(_:)
removeFromSuperview()
insertSubview(_:atIndex:)
insertSubview(_:aboveSubview:)
insertSubview(_:belowSubview:)
exchangeSubviewAtIndex(_:withSubviewAtIndex:)
You can bring your bar to the front using:
view.bringSubviewToFront(nextBar)
Your send your view to the back of the bar using:
nextBar.view.sendSubviewToBack(myView)
For Swift 4:
self.view.sendSubviewToBack(toBack: myView)
In Swift 4.2 it can be done with:
self.sendSubviewToBack(view: viewSentToBack)
An object in the view that is linked by an IBOutlet can be sent to back using the above function.