james james - 1 month ago 6
Swift Question

Xcode can't get colors the same

I have a progress view and a UIView, setup with these values:

healthBar.trackTintColor = UIColor(red: 59/255, green: 153/255, blue: 252/255, alpha: 1.0)
link.backgroundColor = UIColor(red: 59/255, green: 153/255, blue: 252/255, alpha: 1.0)


However, the trackTint color is not the same as the view. It is slightly darker. Any reason for this?

Answer

Assigning the same Color (RGB) as a tint does not gives the same output for original color, thats because:

In color theory, a tint is the mixture of a color with white, which increases lightness, and a shade is the mixture of a color with black, which reduces lightness.

You can find the full Wikipedia resource at this link.

How Can I solve it?

However, you CAN generate the appropriate matching for color and its tintColor, you might want to check these answers.

Hope this helped.

Comments