// 1.取出设置主题的对象
UINavigationBar *navBar = [UINavigationBar appearance];
// 2.设置导航栏的背景图片
NSString *navBarBg = nil;
if (iOS7) { // iOS7
navBarBg = @"NavBar64";
navBar.tintColor = [UIColor whiteColor];
} else { // 非iOS7
navBarBg = @"NavBar";
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;
}
[navBar setBackgroundImage:[UIImage imageNamed:navBarBg] forBarMetrics:UIBarMetricsDefault];
// 3.标题
[navBar setTitleTextAttributes:@{
UITextAttributeTextColor : [UIColor whiteColor]
}];
UINavigationBar *navBar = [UINavigationBar appearance];
// 2.设置导航栏的背景图片
NSString *navBarBg = nil;
if (iOS7) { // iOS7
navBarBg = @"NavBar64";
navBar.tintColor = [UIColor whiteColor];
} else { // 非iOS7
navBarBg = @"NavBar";
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;
}
[navBar setBackgroundImage:[UIImage imageNamed:navBarBg] forBarMetrics:UIBarMetricsDefault];
// 3.标题
[navBar setTitleTextAttributes:@{
UITextAttributeTextColor : [UIColor whiteColor]
}];