4

I want to change my border color to a specific hex color(#21CE99), can you guys please help me?

I've already known how to change it to a basic color, for example:

_button.layer.borderColor = [UIColor greenColor].CGColor;

but I only need this color.

Thank you.

Answer

How to set the custome border color of UIView programmatically in swift

Community
  • 1
  • 1
John E.
  • 321
  • 4
  • 11

3 Answers3

4

The correct answer for people using SWIFT 4 would be:

_button.layer.borderColor = UIColor(red: 33/255, green: 206/255, blue: 153/255, alpha: 1.0).cgColor

Built-In UIColors Presets or your own colors:

_button.layer.borderColor = UIColor.blue.cgColor
Kevin Singh
  • 421
  • 8
  • 14
2
_button.layer.borderColor = [UIColor colorWithRed:33.0 / 255.0 green:206.0 / 255.0 blue:153.0 / 255.0 alpha:1.0].CGColor;
Andrey Chernukha
  • 21,488
  • 17
  • 97
  • 161
1

easier

_button.layer.borderColor = [UIColor colorWithRed:0x21 / 255.0 green:0xce / 255.0 blue:0x99 / 255.0 alpha:1.0].CGColor;
lsdoy
  • 129
  • 12