iOS8: How do I make statusBar opaque after navigationBar is hidden using hidesBarsOnSwipe?

谁都会走 提交于 2019-12-04 01:34:35

Here is a Swift solution:

First, change UITableViewController to UIViewController and add a tableView field. Then, implement your viewDidLoad method as follows:

override func viewDidLoad() {
    super.viewDidLoad()
    tableView.delegate = self
    tableView.dataSource = self
    tableView.frame = view.frame
    view.addSubview(tableView)

    let topBar = UIView(frame: UIApplication.sharedApplication().statusBarFrame)
    topBar.backgroundColor = myDesiredColor
    view.addSubview(topBar)
}

You can add a constraint to the top layout, by this scrolling content will not appear below the status bar.

Make a custom View.

UIView * statusBarView =[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 20)];
statusBarView.backgroundColor=[UIColor whiteColor];
[self.view addSubview:statusBarView];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!