I am creating a UIview using the following code:
UIview* baseView = [[UIview alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
//self.view = baseView;
[self.view addSubview:baseView];
[baseView setBackgroundColor:[UIColor blackColor]];
baseView.userInteractionEnabled = YES;
baseView.alpha = 0.7;
The only problem is that even if I am using the mainScreen option to set it full screen, it appears full screen except for a 5cm line at the top of the UIWindow. Is there any reason for this?
Okay, so the reason why this happens is because [[UIScreen mainScreen] applicationFrame]
will return the frame of the window minus the size of the status bar if it is visible.
To fix it a simple way would be:
UIView* baseView = [[UIView alloc] initWithFrame:CGRectMake(0,
0,
[[UIScreen mainScreen] applicationFrame].size.width,
[[UIScreen mainScreen] applicationFrame].size.height)];
//self.view = baseView;
[self.view addSubview:baseView];
[baseView setBackgroundColor:[UIColor blackColor]];
baseView.userInteractionEnabled = YES;
baseView.alpha = 0.7;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With