搜索时状态栏会更改颜色 [英] Status bar changes color when searching
本文介绍了搜索时状态栏会更改颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是UISearchController
,当单击它时,它会使导航栏上升并将状态栏变成白色.我希望状态栏保持绿色.
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.
我的UISearchController
实现:
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
})()
在点击搜索栏之前
点击搜索栏
推荐答案
发挥丹尼尔·斯托姆(Daniel Storm)的回应.将子视图添加到UISearchController的视图中为我解决了这个问题.
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)
这篇关于搜索时状态栏会更改颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文