Set color of one UIBarButtonItem using IBOutlet

こ雲淡風輕ζ 提交于 2020-03-06 02:20:10

问题


I can't seem to find this anywhere on stack because every solution just mentions how you can set your custom appearance through AppDelegate or through setting the appearance.

All I need is to set ONE and only this one UIBarButtonItem to a custom hexColor using a method called colorWithHexString: that comes from a class extension(added to the project).

my property:

@property (weak, nonatomic) IBOutlet UIBarButtonItem *grNextButton;

what I'm trying to use in my .m file:

grNextButton.tintColor = [UIColor colorWithHexString:@"#669900"];

What is the code that I need to successfully change grNextButton?


回答1:


Use RGBcolor code like this, hope it will solve your problem.

grNextButton.tintColor = [UIColor colorWithRed:255/255.0f 
                                         green:50/255.0f 
                                          blue:60/255.0f 
                                         alpha:1.0f];

The color code I used are example color code you can choose your appropriate color code from here



来源:https://stackoverflow.com/questions/23847976/set-color-of-one-uibarbuttonitem-using-iboutlet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!