Last active
August 29, 2015 13:56
-
-
Save satoshin2071/9166047 to your computer and use it in GitHub Desktop.
[iOS]ステータスバー非表示
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// ステータスバーの表示/非表示メソッド呼び出し | |
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) { | |
// iOS 7以降 | |
[self prefersStatusBarHidden]; | |
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)]; | |
} else { | |
// iOS 7未満 | |
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; | |
} | |
} | |
// ステータスバーの非表示 | |
- (BOOL)prefersStatusBarHidden | |
{ | |
return YES; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
アニメーションさせたくないときは以下を使う | |
//ステータスバー非表示用にオーバーライド | |
- (BOOL)prefersStatusBarHidden { | |
return [[self childViewControllerForStatusBarStyle] preferredStatusBarUpdateAnimation]; | |
} | |
//ステータスバー非表示用にオーバーライド | |
- (UIStatusBarAnimation)preferredStatusBarUpdateAnimation { | |
return [[self childViewControllerForStatusBarStyle] preferredStatusBarUpdateAnimation]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ios7でステータスバーを隠して、前の画面にpopするとステータスバーを隠れていたのを元に戻すためのアニメーションが走るので注意