[UIApplication statusBarFrame]
The frame rectangle defining the area of the status bar. (read-only)
@property(nonatomic, readonly) CGRect statusBarFrame
Discussion
The value of this property is
CGRectZero
if the status bar is hidden.
Example of [UIApplication statusBarFrame]
- (CGRect)statusBarFrameViewRect:(UIView*)view
{
CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
CGRect statusBarWindowRect = [view.window convertRect:statusBarFrame fromWindow: nil];
CGRect statusBarViewRect = [view convertRect:statusBarWindowRect fromView: nil];
return statusBarViewRect;
}
Example of [UIApplication statusBarFrame]
+(CGSize) sizeInOrientation:(UIInterfaceOrientation)orientation
{
CGSize size = [UIScreen mainScreen].bounds.size;
UIApplication *application = [UIApplication sharedApplication];
if (UIInterfaceOrientationIsLandscape(orientation))
{
size = CGSizeMake(size.height, size.width);
}
if (application.statusBarHidden == NO)
{
size.height -= MIN(application.statusBarFrame.size.width, application.statusBarFrame.size.height);
}
return size;
}
Example of [UIApplication statusBarFrame]
CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
// delta is the amount by which the nav bar will be moved
delta = statusBarFrame.size.height + self.navigationController.navigationBar.frame.size.height;
if(statusBarFrame.size.height>20) { // in-call
animationDuration = 0.5;
}
else { // normal status bar
animationDuration = 0.6;
}
// hide status bar
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
// hide nav bar
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:animationDuration];
self.navigationController.navigationBar.frame = CGRectOffset(self.navigationController.navigationBar.frame, 0.0, -delta);
[UIView commitAnimations];