[英]How to change text color for tab bar button in storyboard ios8
我更改了“酒吧色調”字段中的標簽欄背景,並希望更改標簽欄按鈕的文本顏色。 默認情況下為灰色和藍色。 我嘗試在“視圖”部分更改字段“色調”,但這無濟於事。
NSDictionary *attribute = @{NSForegroundColorAttributeName:[UIColor redColor]};
[[UITabBarItem appearance] setTitleTextAttributes:attribute forState:UIControlStateNormal];
這將更改標簽欄按鈕的文本顏色。
這是針對選定狀態的:
[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor redColor]} forState:UIControlStateSelected];
這是未選中狀態:
[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor greenColor]} forState:UIControlStateNormal];
試試吧
要更改標簽欄的文字顏色,您可以使用此
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary [UIColor redColor], UITextAttributeTextColor,[UIColor redColor],UITextAttributeTextShadowColor,[NSValue valueWithUIOffset:UIOffsetMake(0, 0.5)], UITextAttributeTextShadowOffset,[UIFont fontWithName:@"Arial" size:10], UITextAttributeFont,nil]forState:UIControlStateNormal];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.