我正在使用一个UISearchController,当点击时,使导航栏上升并将状态栏变成白色。我希望状态栏保持绿色。
我的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
})()
Run Code Online (Sandbox Code Playgroud)
小智 6
播放丹尼尔风暴的回应。将子视图添加到 UISearchController 的视图为我解决了这个问题。
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)
Run Code Online (Sandbox Code Playgroud)
UIView在状态栏后面放置一个带有您需要的背景颜色的颜色。
let statusBarView = UIView(frame: UIApplication.sharedApplication().statusBarFrame)
statusBarView.backgroundColor = UIColor.greenColor() // Replace with color you desire
view.addSubview(statusBarView)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1799 次 |
| 最近记录: |