When hiding the statusbar my navigation bar moves up in iOS7

前端 未结 5 495
逝去的感伤
逝去的感伤 2021-01-31 16:05

I am trying to hide the statusbar but maintain the \"bigger\" navigationbar height. Right now when I hide the statusbar by setting - (BOOL)prefersStatusBarHidden to

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-31 16:54

    Another workaround here: subclass UINavigationController override method:

    - (void)viewWillLayoutSubviews
    {
        [super viewWillLayoutSubviews];
        if (self.navigationBar.frameMinY < 1) {
            self.navigationBar.frameHeight = 64;
        } else {
            self.navigationBar.frameHeight = 44;
        }
    }
    

    in which set frameMinY is set frame.origin.y and set frameHeight is set frame.size.height

提交回复
热议问题