2017-09-01 86 views
1

我得到一个输出,内容为ExtendedSRGB。我已经给我了以下的输出:将SRGB值作为背景颜色显示到视图

我需要显示在UIViewSRGB颜色,所以它看起来是这样的:

self.view.backgroundColor = SRGB VALUES 

但是,与RGBSRGB值的范围从0..1。因此,如何显示颜色。

[ (kCGColorSpaceICCBased; kCGColorSpaceModelRGB;的sRGB IEC61966-2.1)]( 0.745098 0.745098 1 1)

回答

0
尝试

代码如下:

let sRGB = CGColorSpace(name: CGColorSpace.sRGB)! 
let cgRequiredColor = CGColor(colorSpace: sRGB, components: [0.745098, 0.745098, 1, 1])! 
let requiredColor = UIColor(cgColor: cgRequiredColor) 
self.view.backgroundColor = requiredColor 

作为每sRGV值,输出是:

enter image description here

更多的东西,参考链接:

https://codexample.org/questions/779247/how-do-i-compare-2-uicolor-objects-which-are-kcgcolorspacemodelrgb-and-uiextendedsrgbcolorspace-instances-in-logs.c iOS - color on xcode simulator is different from the color on device hex colors in iOS are not accurate

希望将帮助!

+0

从我的输出中,我怎样才能提取值'[0.745098,0.745098,1,1]'? – Illep