Reputation: 7367
I have a UISearchController
in my view controller, when the searchBar
is active the status bar becomes transparent. I've tried this and this but none of them worked.
This is the view hierarchy of the view controller:
How can I make the status bar translucent?
Upvotes: 2
Views: 480
Reputation: 7367
Using this in viewDidLoad
solved the problem:
var frame = UIApplication.shared.statusBarFrame
frame = CGRect(x: 0, y: 0, width: frame.width, height: frame.height*3.3)
//3.3 is a practical number
let statusBarView = UIView(frame: frame)
statusBarView.backgroundColor = sharedApplication.mainThemeColor
searchController.view.addSubview(statusBarView)
Upvotes: 1