5.设置NavgationBar的风格
-(void)setNavBar
{
UINavigationBar *navBar = [UINavigationBar appearance];
[navBar setBackgroundImage:[UIImage imageNamed:@"NavBar64"] forBarMetrics:UIBarMetricsDefault];
NSMutableDictionary *dm = [NSMutableDictionary dictionary];
dm[NSFontAttributeName] = [UIFont systemFontOfSize:16];
dm[NSForegroundColorAttributeName] = [UIColor whiteColor];
[navBar setTitleTextAttributes:dm];
[navBar setTintColor:[UIColor whiteColor]];
}
6.设置UIBarButtonItem:
在storyboard中拖一个UIBarButtonItem然后它的图片和文字颜色默认是蓝色,可以调整tint设置为白色!
也可以在代码中实现navgationBar风格那样,给UIBarButtonItem设置风格
UIBarButtonItem *barItem = [UIBarButtonItem appearance];
if (!iOS7) {
UIImage *norImage = [UIImage imageNamed:@"NavButton"];
[barItem setBackgroundImage:norImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
UIImage *higImage = [UIImage imageNamed:@"NavButtonPressed"];
[barItem setBackgroundImage:higImage forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
UIImage *norBackImage = [UIImage imageNamed:@"NavBackButton"];
[barItem setBackButtonBackgroundImage:norBackImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
UIImage *higBackImage = [UIImage imageNamed:@"NavBackButtonPressed"];
[barItem setBackButtonBackgroundImage:higBackImage forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
}else
{
NSMutableDictionary *barMd = [NSMutableDictionary dictionary];
barMd[NSFontAttributeName] = [UIFont systemFontOfSize:16];
barMd[NSForegroundColorAttributeName] = [UIColor whiteColor];
[barItem setTitleTextAttributes:barMd forState:UIControlStateNormal];
}