I'm using a UISearchController
that, when clicked, makes the navigation bar rise and turn the status bar white. I want the status bar to remain green.
My UISearchController
implementation:
self.resultSearchController = ({
let controller = UISearchController(searchResultsController: nil)
controller.searchResultsUpdater = self
controller.dimsBackgroundDuringPresentation = false
controller.searchBar.sizeToFit()
controller.searchBar.placeholder = "Pesquisa por linha ou cod..."
controller.searchBar.tintColor = UIColor(netHex: 0xFFFFFF)
controller.searchBar.barTintColor = UIColor(netHex: 0x2F7C30)
controller.searchBar.clipsToBounds = true
controller.searchBar.layer.borderWidth = 1;
controller.searchBar.layer.borderColor = UIColor(netHex: 0x2F7C30).CGColor
self.navigationController!.view.backgroundColor = UIColor(netHex: 0x2F7C30)
self.tableView.tableHeaderView = controller.searchBar
return controller
})()
Before clicking on the search bar
After clicking on the search bar
Playing off of Daniel Storm's response. Adding the subview to the UISearchController's view solved the issue for me.
let statusBarView = UIView(frame: CGRectMake(0, 0,
UIApplication.sharedApplication().statusBarFrame.size.width,
UIApplication.sharedApplication().statusBarFrame.size.height))
statusBarView.backgroundColor = Colors.Primary.Regular
searchController.view.addSubview(statusBarView)
Put a UIView
behind your status bar with the background color you need.
let statusBarView = UIView(frame: UIApplication.sharedApplication().statusBarFrame)
statusBarView.backgroundColor = UIColor.greenColor() // Replace with color you desire
view.addSubview(statusBarView)
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