[英]change text color of Bar Button Item from storyboard
我將情節提要中的“條形按鈕”項拖放到了情節提要創建的導航欄上。
我想知道如何從情節提要中更改Bar Button Item的文本顏色嗎?
我嘗試為條形按鈕項目創建插座,然后嘗試:
[myBackButton.titleLabel.textColor = [UIColor blackColor]];
甚至嘗試過barbuttonItem:
[myButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
但是我遇到一個錯誤。 我嘗試更改色調以改變背景顏色,但文本顏色仍為白色如何將文本顏色更改為黑色? 提前致謝。
您可以使用Attributes更改文本顏色。 例如,
NSDictionary *attributes = @{UITextAttributeTextColor : [UIColor redcolor]};
[myButton setTitleTextAttributes:attributes
forState:UIControlStateNormal];
我認為這會有所幫助
[[UIBarButtonItem appearance] setTintColor:[UIColor yellowColor]];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.