3

Is there a mean in SWIFT to define my own custom color? and call it with:

mybutton.backgroundColor = UIColor.mycustomcolor

I need to use mycustomcolor many times in my app.

Thanks

cmii
  • 3,476
  • 7
  • 37
  • 64

1 Answers1

6

Try something like this:

extension UIColor {

    static let myCustomColor = UIColor(red: 1, green: 1, blue: 1, alpha: 1)

}
Ivan Smetanin
  • 1,949
  • 2
  • 18
  • 28