I found that after setting the
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO]
at viewDidLoad
, then if I want to align an image to the top, I will need to set its position as .y = -20;
Is there anyway to make the y coordinate of the top position to 0 ? or is it doomed to be -20 after hidding the status bar?
Thanks for reading.
I had a similar problem at one point and this bit of code fixed it for me:
[viewController.view setFrame: [viewController.view bounds]];
Justin Gallagher's solution is almost right, but has one major side effect.
Hiding the status bar and then setting the view's frame to its own bounds will work in the current orientation. But rotation will be ugly. If you are in portrait, for instance, rotating the device to landscape will cause the entire view's frame to be shifted to the right 256 points, leaving a large black space on screen.
bmoeskau's solution (to another side effect) in the comments above avoids this problem:
[self.view setFrame: [[UIScreen mainScreen] bounds]];
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