ios - 来自 nib 颜色选择器的颜色不同于 [UIColor -colorWithRed :green:blue:alpha:]

标签 ios

我想在整个应用程序中使用某种颜色。该颜色具有这些 RGBA 值:

R:217 后腰:66 乙:60 答:1.0

现在,在某些 Nib 中,我通过颜色选择器将此颜色用作背景颜色。 在其他情况下,我使用此代码手动设置颜色

[UIColor colorWithRed:217.f/255.f green:66.f/255.f blue:60.f/255.f alpha:1.0f];

但是,我发现颜色在视觉上不匹配!!

enter image description here

enter image description here 到底是怎么回事?为什么颜色看起来如此不同?

打印出颜色给我这个:

(lldb) po [self.programticLabel backgroundColor]
UIDeviceRGBColorSpace 0.85098 0.258824 0.235294 1

(lldb) po [self.nibLabel backgroundColor]
UIDeviceRGBColorSpace 0.805696 0.171843 0.181392 1

最佳答案

啊哈!答案可以在这里找到:

Weird colors in XCode Interface Builder?

如果您转到 Xcode 中的 RGB 颜色选择器 - 请务必注意下拉菜单右侧的设置按钮。 RGB 被定义为颜色空间的一部分——我的设置没有设置为 Apple 的。

关于ios - 来自 nib 颜色选择器的颜色不同于 [UIColor -colorWithRed :green:blue:alpha:],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26371916/

相关文章:

ios - CMSampleBuffer 中的 UIImage 呈蓝色

ios - 基于字符串数组 (Swift) 在 UITableView 中的 viewdidload 上选择单元格

html - -webkit-overflow-scrolling 是否适合生产使用?

ios - 如何获取 SVGElement 所属的组?

ios - iOS 中的辅助功能 : providing a brief description of a screen

ios - (BOOL)openSessionWithAllowLoginUI :(BOOL)allowLoginUI is never called

ios - 从文件中获取字节数据

iphone - 为什么我的属性 getter 会导致 NSZombie 错误?

ios - Swift - 不可转换为 'NativeObject'

ios - 带有放大镜且没有键盘的 UITextView