[[UIScreen mainScreen] bounds]
gives the correct size of the entire window, but it includes the size of the status bar. If you want the size of the status bar ( you can subtract its height), you should use [[UIApplication sharedApplication] statusBarFrame]
to get the frame of the status bar. Navigation bars and tab bars generally have a height of 44. So, use CGRectMake()
if you need a rectangle for your view:
CGRect frame_screen = [[UIScreen mainScreen] bounds];
CGRect frame_view = CGRectMake(0,0,frame_screen.size.width,frame_screen.size.height - [[UIApplication sharedApplication] statusBarFrame].size.height);
Notice that the last argument of CGRectMake
is the height, usually you can minus 44 for a tab bar or navigation bar.
EDIT: Try to log [UIScreen mainScreen].applicationFrame
and [[UIScreen mainScreen] bounds]
to console and see what the difference is between them. Something like
CGRect frame_screen = [[UIScreen mainScreen] bounds];
NSLog(@"x: %f, y: %f, width: %f, height: %f",frame_screen.origin.x,frame_screen.origin.y,frame_screen.size.width,frame_screen.size.height);
CGRect frame_application = [UIScreen mainScreen].applicationFrame
NSLog(@"x: %f, y: %f, width: %f, height: %f",frame_application.origin.x,frame_application.origin.y,frame_application.size.width,frame_application.size.height);
Then use that information to make [[UIScreen mainScreen] bounds
frame how you need it.