在NavigationController中, initialize 方法中,
在程序運行過程中,它會在你程序中每個類調用一次initialize
涂乌。這個調用的時間發(fā)生在你的類接收到消息之前埂淮,但是在它的超類接收到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];
}