0

I want to have color border on button:

buyButton.layer.borderColor = UIColor(red: 83.0, green: 186.0, blue: 183.0, alpha: 1.0).cgColor

doesn't work for me, but

 buyButton.layer.borderColor = UIColor.blue.cgColor

works. What is wrong with my color?

Thank you

David
  • 825
  • 10
  • 33

2 Answers2

0

You are using 'raw' RGB values, divide them by 255.0.

buyButton.layer.borderColor = UIColor(red: 83.0/255.0, green: 186.0/255.0, blue: 183.0/255.0, alpha: 1.0).cgColor

So in UIColor terms, 1.0 is 255 red. 0.5 is 127.5 red etc.

Erik Terwan
  • 2,710
  • 19
  • 28
0

The input values needs to be between 0 and 1, so divide them by 255.

buyButton.layer.borderColor = UIColor(red: 83.0/255.0, green: 186.0/255.0, blue: 183.0/255.0, alpha: 1.0).cgColor