#pragma mark 一個類只會調用一次app
+ (void)initializespa
{orm
// 1.取出設置主題的對象對象
UINavigationBar *navBar = [UINavigationBarappearance];圖片
UIBarButtonItem *barItem = [UIBarButtonItemappearance];it
// 2.設置導航欄的背景圖片io
NSString *navBarBg = nil;sed
if (iOS7) { // iOS7im
navBarBg = @"NavBar64";樣式
// 設置導航欄的漸變色爲白色(iOS7中返回箭頭的顏色變爲這個顏色:白色)
navBar.tintColor = [UIColor whiteColor];
} else { // 非iOS7
navBarBg = @"NavBar";
[UIApplicationsharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;
// 設置導航欄按鈕的背景圖片
[barItem setBackgroundImage:[UIImageimageNamed:@"NavButton"] forState:UIControlStateNormalbarMetrics:UIBarMetricsDefault];
[barItem setBackgroundImage:[UIImageimageNamed:@"NavButtonPressed"] forState:UIControlStateHighlightedbarMetrics:UIBarMetricsDefault];
// 設置導航欄返回按鈕的背景圖片
[barItem setBackButtonBackgroundImage:[UIImageimageNamed:@"NavBackButton"] forState:UIControlStateNormalbarMetrics:UIBarMetricsDefault];
[barItem setBackButtonBackgroundImage:[UIImageimageNamed:@"NavBackButtonPressed"] forState:UIControlStateHighlightedbarMetrics:UIBarMetricsDefault];
}
[navBar setBackgroundImage:[UIImageimageNamed:navBarBg] forBarMetrics:UIBarMetricsDefault];
// 3.設置導航欄標題顏色爲白色
[navBar setTitleTextAttributes:@{
UITextAttributeTextColor : [UIColorwhiteColor]
}];
// 4.設置導航欄按鈕文字顏色爲白色
[barItem setTitleTextAttributes:@{
UITextAttributeTextColor : [UIColorwhiteColor],
UITextAttributeFont : [UIFontsystemFontOfSize:13]
}forState:UIControlStateNormal];
}
#pragma mark 控制狀態欄的樣式
/*
狀態欄的管理:
1> iOS7以前:UIApplication
2> iOS7開始:交給對應的控制器去管理
*/
- (UIStatusBarStyle)preferredStatusBarStyle
{
// 白色樣式
returnUIStatusBarStyleLightContent;
}