Search code examples
iosswiftuicolor

How to define my own custom UIColor?


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


Solution

  • Try something like this:

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