iOS 7 status bar like iOS 6

前端 未结 5 1310
南笙
南笙 2021-02-08 04:05

I have an app with a support landscape and portrait mode. And I need the same behavior status bar like on iOS 6. What is the simplest way to do this?

I\'ve tried the sol

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-08 05:03

    You can try writing this in your ViewWillappear or DidAppear. Here we are shifting the view frame 20 pixels down.

    CGRect frame = self.view.frame;
    frame.origin.y = 20;
    
    if (self.view.frame.size.height == 1024 || 
        self.view.frame.size.height == 768)
    {
        frame.size.height -= 20;
    }
    
    self.view.frame = frame;
    

    This will work, but however this is not a very good idea. You can also change the text colour of the status bar to light or dark depending on your app background by calling the following method if it helps.

    -(UIStatusBarStyle)preferredStatusBarStyle
    {
         return UIStatusBarStyleLightContent; // For light status bar
    
         return UIStatusBarStyleDefault // For Dark status bar
    }
    

提交回复
热议问题