UIView Fullscreen Problems
I am trying to get my UIView to fill the entire screen. I've tried the code below, which works, but always leaves a white line where the status bar was below. No matter what size i set the frame of the UIView
, this line always remains there. What am I missing?
[[UIAppli开发者_开发问答cation sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
[view setFrame:[[UIScreen mainScreen] applicationFrame]];
[view setNeedsLayout];
It's highly likely that your view controller's view's frame was set to the applicationFrame
and since you're adding the view
as it's subview, the frame of your view
will be within its parent view's bounds.
You will have to adjust the view controller's view first and then follow it up by adding the view.
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
self.view.frame = [[UIScreen mainScreen] applicationFrame];
view.frame = self.view.bounds;
[view setNeedsLayout];
You will also need to set the autoresizingMask
if you think self.view.frame
might change.
精彩评论