Rogare
Rogare

Reputation: 3274

Hiding status bar: effect on bounds

I'm working through the Big Nerd Ranch's iOS Programming book (3rd edition), and there's one particular example that involves a full screen image embedded in a full screen UIScrollView. Both are created as follows:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
CGRect screenRect=[[self window] bounds];
UIScrollView *scrollView=[[UIScrollView alloc] initWithFrame:screenRect];
view=[[HypnosisView alloc] initWithFrame:screenRect];

We're asked to make the status bar disappear using the following line:

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];

Everything works fine, but what I don't understand is this: why are the window's bounds the same regardless of whether or not the status bar is there? They are always (0,0,320,568), but I would have expected the height to shrink if I hid the status bar.

Thanks for reading.

Upvotes: 1

Views: 172

Answers (1)

Bijoy Thangaraj
Bijoy Thangaraj

Reputation: 5546

[UIScreen mainScreen] bounds] always returns the frame of the device which will be the same for the device always irrespective of weather your app shows or hides the status bar.

Upvotes: 1

Related Questions