Position of navigation bar for modal view - iOS7

前端 未结 8 2249
南笙
南笙 2020-11-29 18:08

In a navigation controller, you automatically get the correct colour and position of a navigation bar as expected.

like this

8条回答
  •  佛祖请我去吃肉
    2020-11-29 19:00

    After a few tries to move Navigation Bar few pixels down in iOS 7, this is what finally worked for me:

    -(void)viewWillLayoutSubviews
    {
        float iosVersion = 7.0;
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= iosVersion) {
            // iOS 7+
            CGRect viewFrame = self.view.frame;
            viewFrame.origin.y += 10;
            self.view.frame = viewFrame;
        }
    }
    

    I also adjusted the Status Bar color to better match my content:

    -(UIStatusBarStyle)preferredStatusBarStyle{
        return UIStatusBarStyleLightContent;
    }
    

提交回复
热议问题