So, I have a button that I added to main.Storyboard, as well as the main background for the view, and then in the viewController.swift file, I created the UIView rectangle shape that I want to sit behind this button (as the background for it) .
The problem is that when I added the UIView rectangle, it always added it before the button. So I searched online and found the sendSubviewToBack code. I added this, but it sends it completely behind the main background of the UIImage view.
Is there a way that I can just send this UIView behind the button, but before the UIImage background?
func nextBarDisplayed() { let theHeight = self.view.frame.height nextBar.backgroundColor = UIColor(red: 7/255, green: 152/255, blue: 253/255, alpha: 0.5) nextBar.frame = CGRect(x: 0, y: theHeight - 50, width: self.view.frame.width, height: 50) self.view.insertSubview(nextBar, aboveSubview: myBackgroundView) }
ios iphone swift uiview
Nick89
source share