Trombone0904
Trombone0904

Reputation: 4258

change tint color of UIBarButtonItem

I would like to change the text color of my UIBarButtonItem. Current color is "system blue"

I tried this:

let button = UIBarButtonItem(title: "Button", style: .plain, target: self, action: #selector(exit))
button.tintColor = UIColor(red: 126.0, green: 189.0, blue: 11.0, alpha: 1.00)

The rgb values should show a green color - but the button text color shows white. Where is my fault ?

Upvotes: 0

Views: 111

Answers (1)

Kishan Bhatiya
Kishan Bhatiya

Reputation: 2368

You have to set values between 0 to 1 for RGB Colors. Use the following

UIColor(red: 126.0/255.0, green: 189.0/255.0, blue: 11.0/255.0, alpha: 1.00)

OR

UIColor(red: 0.49, green: 0.74, blue: 0.04, alpha: 1.00)

Upvotes: 1

Related Questions