在NavigationController中, initialize 方法中,
在程序运行过程中,它会在你程序中每个类调用一次initialize
。这个调用的时间发生在你的类接收到消息之前,但是在它的超类接收到initialize之后。
关于initialize, 请参考 http://blog.csdn.net/ajrm0925/article/details/7431982/
+ (void)initialize
{
/** 设置UINavigationBar */
UINavigationBar *bar = [UINavigationBar appearance];
// 设置导航栏的背景
bar.barTintColor = [UIColor colorWithHexString:@"#0abdc8" andAlph:1];
// 设置背景
// [bar setBackgroundImage:[UIImage imageNamed:@"navigationbarBackgroundWhite"] forBarMetrics:UIBarMetricsDefault];
// 设置标题文字属性
NSMutableDictionary *barAttrs = [NSMutableDictionary dictionary];
if (SCREEN_WIDTH == 320) { // 3.5’设备
barAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:18];
} else { // 其他设备
barAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:19];
}
// bar.tintColor = [UIColor whiteColor]; 设置导航栏字体颜色
barAttrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
[bar setTitleTextAttributes:barAttrs];
/** 设置UIBarButtonItem */
UIBarButtonItem *item = [UIBarButtonItem appearance];
// UIControlStateNormal
NSMutableDictionary *normalAttrs = [NSMutableDictionary dictionary];
normalAttrs[NSForegroundColorAttributeName] = [UIColor blackColor];
normalAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:17];
[item setTitleTextAttributes:normalAttrs forState:UIControlStateNormal];
// UIControlStateDisabled
NSMutableDictionary *disabledAttrs = [NSMutableDictionary dictionary];
disabledAttrs[NSForegroundColorAttributeName] = [UIColor grayColor];
[item setTitleTextAttributes:disabledAttrs forState:UIControlStateDisabled];
}