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

后端 未结 3 769
心在旅途
心在旅途 2021-02-20 03:35

I am building iOS8 app. On my tableview controller, I am using self.navigationController.hidesBarsOnSwipe = YES, to hide the navigationBar on swipe up gesture. It is working nic

相关标签:
3条回答
  • 2021-02-20 04:03

    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)
    }
    
    0 讨论(0)
  • 2021-02-20 04:09

    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];
    
    0 讨论(0)
  • 2021-02-20 04:10

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

    0 讨论(0)
提交回复
热议问题