iOS 7 status bar back to iOS 6 default style in iPhone app?

前端 未结 25 857
终归单人心
终归单人心 2020-11-22 05:48

In iOS 7 the UIStatusBar has been designed in a way that it merges with the view like this:

\"GUI

25条回答
  •  旧巷少年郎
    2020-11-22 06:38

    As using presentViewController:animated:completion: messed-up the window.rootViewController.view, I had to find a different approach to this issue. I finally got it to work with modals and rotations by subclassing the UIView of my rootViewController.

    .h

    @interface RootView : UIView
    
    @end
    

    .m

    @implementation RootView
    
    -(void)setFrame:(CGRect)frame
    {
        if (self.superview && self.superview != self.window)
        {
            frame = self.superview.bounds;
            frame.origin.y += 20.f;
            frame.size.height -= 20.f;
        }
        else
        {
            frame = [UIScreen mainScreen].applicationFrame;
        }
    
        [super setFrame:frame];
    }
    
    - (void)layoutSubviews
    {
        self.frame = self.frame;
    
        [super layoutSubviews];
    }
    
    @end
    

    You now have a strong workaround for iOS7 animations.

提交回复
热议问题