Search code examples
swiftxcodeheighthidestatusbar

swift 3: How to hide status bar without losing height


When I hide the status bar in one page from the uipageviewcontroller then move the whole content up.

override var prefersStatusBarHidden: Bool {
    return true
}

Show images

how can I solve this problem?


Solution

  • Set the top constraint to Top Layout Guide instead of View in interface builder. Like so

    enter image description here

    Top Layout Guide will be based on the status bar (or phone call, etc.) Where view will be a static value ignoring if the view has a status bar or not.