[英]How to change navigation bar title color?
我試圖這樣更改標題顏色,但沒有效果。
NSDictionary *navbarTitleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil];
[[UINavigationBar appearance] setTitleTextAttributes:navbarTitleTextAttributes];
導航欄樣式可能是黑色的問題?
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
使用UITextAttributeTextColor
而不是NSForegroundColorAttributeName
作為密鑰,它將起作用:)
嘗試這個 :
self.navigationItem.title = @"The title";
self.navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor redColor] forKey:NSForegroundColorAttributeName];
嘗試使用控制器的navigationBar的實例
UIFont* font = kRobotoMedium(21));
[controller.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:font}];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.