IOS:StatusBar
The status bar displays important information about the device and the current environment (shown below on iPhone).
Status Bar Black Error
아래의 그림과 같이 상태바(StatusBar)가 검은색으로 출력되었을 경우 해결할 수 있는 방법에 대하여 정리한다.
Ios7_statusbar_error_sample.png
- 아래의 "iOS7 StatusBar Style"참조
- UIViewController의 "Hide Status Bar"부분 참조: StatusBar를 출력하도록
prefersStatusBarHidden
함수의 반환값을NO
로 변경하면 된다.
iOS7 StatusBar Style
IOS7로 업데이트되면서 우리가 제어할 수 있는게 몇가지 늘어났는데 이중 하나가 StatusBar입니다. UIViewController
에 아래와 같이 정의되어 있다.
// These methods control the attributes of the status bar when this view controller is shown. They can be overridden in view controller subclasses to return the desired status bar attributes.
- (UIStatusBarStyle)preferredStatusBarStyle NS_AVAILABLE_IOS(7_0); // Defaults to UIStatusBarStyleDefault
이 함수를 아래와 같이 재정의(Override)하면 된다.
iOS7 StatusBar 겹침 현상
iOS 버전 업데이트와 동시에 6, 7 버전의 차이로 인해 상태바의 위치가 변경됨. 기존 6버전 에서는 20px만큼의 고정된 영역을 차지하던 상태바가, 7버전에서는 고정된 영역이 아닌 겹쳐지는 영역을 사용하는 방식으로 바뀐듯. 해결 방법으로, AppDelegate
의 didFinishLaunchingWithOptions
함수에 아래와 같은 내용을 추가하면 된다.
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
// [application setStatusBarStyle:UIStatusBarStyleLightContent];
self.window.clipsToBounds = YES;
self.window.frame = CGRectMake(0, 20, self.window.frame.size.width,self.window.frame.size.height - 20);
self.window.bounds = CGRectMake(0, 0, self.window.frame.size.width, self.window.frame.size.height);
}
또는 아래와 같이 간단하게 해결할 수 있다.
CGRect frame = self.navigationController.view.frame;
frame.origin.y = 20;
self.navigationController.view.frame = frame;
Favorite site
Technical Q&A: iOS7 StatusBar
- Developer apple: Preventing the Status Bar from Covering Your Views
- Developer apple: UIBarPositioningDelegate Protocol Reference
iOS7 StatusBar 관련 이슈
- iOS 7 status bar back to iOS 6 style's issue 1
- iOS 7 status bar back to iOS 6 style? 2
- Status bar and navigation bar issue in IOS7 3
- IOS7_StatusBar와 CustomNavigationBar 4
- iOS 7 Development Tips, Tricks & Hacks