Search code examples
iosswiftuitableviewstatusbar

How to bring TableViewController to back


I've a UITableViewController.

But when I'm scrolling to top, table data can be seeing on the status bar like this:

How can I bypass this moment?


Solution

  • You can hide status bar using next snippet:

    override func prefersStatusBarHidden() -> Bool {
        return true;
    }
    

    Or you can set contentInsets

    self.tableView.contentInset = UIEdgeInsetsMake(60, 0, 0, 0)
    

    There possibly other solutions (like changing constraint of tableView) depends on your requirements