狀態(tài)欄設(shè)置為白色
在info.plist文件中設(shè)置:
-
View controller-based status bar appearance
為NO -
Status bar style
為 Opaque black style
配置如下圖:
** 注意: **這么設(shè)置后仿滔,會(huì)導(dǎo)致橫屏狀態(tài)下狀態(tài)欄消失,所以可以采取下面的方式(刪除上面2個(gè)配置的屬性),新建一個(gè)UIViewController的基類,然后重寫它的prefersStatusBarHidden
方法和preferredStatusBarStyle
方法,如下:
- (BOOL)prefersStatusBarHidden {
return NO;
}
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
iOS橫屏狀態(tài)欄不顯示解決辦法:
1.在plist文件中將View controller-based status bar appearance
設(shè)置為NO
2.在application:didFinishLaunchingWithOptions:中添加下面代碼:
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
導(dǎo)航欄設(shè)置顏色
[[UINavigationBar appearance] setBarTintColor:[UIColor purpleColor]];
設(shè)置UIBarButtonItem的顏色
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
設(shè)置導(dǎo)航欄的字體
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor], NSFontAttributeName : [UIFont systemFontOfSize:18]}];
設(shè)置導(dǎo)航欄返回鍵的標(biāo)題
//在上一級VC中添加如下代碼
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] init];
backItem.title = @"";
self.navigationItem.backBarButtonItem = backItem;