cgcolor
Convert CGColor to corresponding UIColor in Swift
Get the UIColor from the CGColor using UIColor(cgColor: …): let uiColor = UIColor(cgColor: cgColor) then assign it as a background color to your button.
Extracting rgb from UIColor [duplicate]
The code sample you provided should work. Try this: UIColor uicolor = [[UIColor greenColor] retain]; CGColorRef color = [uicolor CGColor]; int numComponents = CGColorGetNumberOfComponents(color); if (numComponents == 4) { const CGFloat *components = CGColorGetComponents(color); CGFloat red = components[0]; CGFloat green = components[1]; CGFloat blue = components[2]; CGFloat alpha = components[3]; } [uicolor release];