ios - CGColor not defined for the UIColor UIDeviceRGBColorSpace 1 1 0 1 -


application crash , have error in xcode console:

nsinvalidargumentexception', reason: '*** -cicolor not defined uicolor uidevicergbcolorspace 1 1 0 1; need first convert colorspace. 

when try display value of rgb color :

 var color:uicolor  print("color \(color.cicolor.red)  \(color.cicolor.green)  \(color.cicolor.blue)") 

from cicolor doc:

var cicolor: cicolor { }

the core image color associated receiver. (read-only) property throws exception if color object not initialized core image color.

use getred method rgb:

var color = uicolor.redcolor() var fred: cgfloat = 0 var fgreen: cgfloat = 0 var fblue: cgfloat = 0 var falpha: cgfloat = 0 if color.getred(&fred, green: &fgreen, blue: &fblue, alpha: &falpha) {     print("color \(fred)  \(fgreen)  \(fblue)") } else {     print("error: color not converted") } 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -