简体   繁体   English

从情节提要中更改Bar Button Item的文本颜色

[英]change text color of Bar Button Item from storyboard

I have dragged and dropped Bar Button Item in Storyboard over navigation bar created by storyboard. 我将情节提要中的“条形按钮”项拖放到了情节提要创建的导航栏上。
I would like to know how to change text color of Bar Button Item from storyboard ? 我想知道如何从情节提要中更改Bar Button Item的文本颜色吗?
I have tried creating an outlet for bar button item then tried : 我尝试为条形按钮项目创建插座,然后尝试:
[myBackButton.titleLabel.textColor = [UIColor blackColor]];

even tried barbuttonItem : 甚至尝试过barbuttonItem:

[myButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; 

but I am getting an error . 但是我遇到一个错误。 I tried changing tint the background color changes but the text color is still white How do I Change the text color to black? 我尝试更改色调以改变背景颜色,但文本颜色仍为白色如何将文本颜色更改为黑色? Thanks in Advance. 提前致谢。

You can change the text color using Attributes . 您可以使用Attributes更改文本颜色。 For instance, 例如,

NSDictionary *attributes = @{UITextAttributeTextColor : [UIColor redcolor]};
[myButton setTitleTextAttributes:attributes
                      forState:UIControlStateNormal];

我认为这会有所帮助

[[UIBarButtonItem appearance] setTintColor:[UIColor yellowColor]];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM