Swift how can we convert lightBluecolor.CGColor to corresponding UIColor

Jyothish Jose picture Jyothish Jose · Mar 5, 2015 · Viewed 11.5k times · Source

I am using a CGColor lightbluecolor and now I want to use the exact color as background of a uiButton. How can I achieve this?

Answer

Valentin picture Valentin · Mar 5, 2015

Get the UIColor from the CGColor using UIColor(cgColor: ...):

let uiColor = UIColor(cgColor: cgColor)

then assign it as a background color to your button.