Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define my own custom UIColor? [duplicate]

Tags:

ios

swift

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

like image 519
cmii Avatar asked Oct 29 '25 09:10

cmii


1 Answers

Try something like this:

extension UIColor {

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

}
like image 52
Ivan Smetanin Avatar answered Oct 31 '25 01:10

Ivan Smetanin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!