Set color of one UIBarButtonItem using IBOutlet

2019-08-22 07:21发布

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条回答
我想做一个坏孩纸
2楼-- · 2019-08-22 07:43

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

查看更多
登录 后发表回答