4

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,556
  • 8
  • 38
  • 69

1 Answers1

7

Try something like this:

extension UIColor {

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

}
Ivan Smetanin
  • 1,999
  • 2
  • 21
  • 28