歲數大了,記憶不行了,還是爛筆頭靠譜,直接上代碼,以備后期自己使用
第一種:
UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 44)];
title.text = @"全國小記者互動平臺";
title.font = kFont(18);
title.textAlignment = NSTextAlignmentCenter;
title.textColor = [UIColor whiteColor];
// 給導航標題設置一個自定義View
self.navigationItem.titleView = title;
第二種 比較簡單 推薦使用:
// 直接獲取導航欄唯一對象
UINavigationBar *bar = [UINavigationBar appearance];
// bar.barTintColor = [UIColor redColor];
// 設置標題顏色字典
NSDictionary *dictAttr = @{NSForegroundColorAttributeName:[UIColor whiteColor]};
bar.titleTextAttributes = dictAttr;
第三種 后期在補:
Loading......