UIView background sizing issue

后端 未结 7 751
梦如初夏
梦如初夏 2021-01-28 07:06

I\'m adding a UIImageView to the UIViewController\'s UIView as I would normally, with the frame of the image view being the same as self.view to make sure that the

7条回答
  •  故里飘歌
    2021-01-28 07:30

    In your app delegate set the FullScreenLayout to YES just before you make it the view controller the root view controller:

    ViewController *vc = [[ViewController alloc] init];
    [vc setWantsFullScreenLayout:YES];
    [[self window] setRootViewController:vc];
    

    or you can set it in viewDidLoad

    [self setWantsFullScreenLayout:YES];
    

    A summary on setWantsFullScreenLayout: When a view controller presents its view, it normally shrinks that view so that its frame does not overlap the device’s status bar. Setting this property to YES causes the view controller to size its view so that it fills the entire screen, including the area under the status bar. (Of course, for this to happen, the window hosting the view controller must itself be sized to fill the entire screen, including the area underneath the status bar.) You would typically set this property to YES in cases where you have a translucent status bar and want your view’s content to be visible behind that view. From here

    Hope this helps.

提交回复
热议问题