gpt4 book ai didi

ios - 未为 UIColor UIDeviceRGBColorSpace 定义 CGColor 1 1 0 1

转载 作者:可可西里 更新时间:2023-11-01 02:15:46 24 4
gpt4 key购买 nike

应用程序崩溃,我的 Xcode 控制台出现此错误:

NSInvalidArgumentException', reason: '*** -CIColor not defined for the UIColor UIDeviceRGBColorSpace 1 1 0 1; need to first convert colorspace.

当我尝试显示 RGB 颜色的值时:

 var color:UIColor
print("color \(color.CIColor.red) \(color.CIColor.green) \(color.CIColor.blue)")

最佳答案

来自 CIColor 文档:

var CIColor: CIColor { get }

The Core Image color associated with the receiver. (read-only) This property throws an exception if the color object was not initialized with a Core Image color.

使用getRed方法获取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 could not be converted")
}

关于ios - 未为 UIColor UIDeviceRGBColorSpace 定义 CGColor 1 1 0 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38635041/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com