简体   繁体   English

Xcode 8:界面构建器显示设置的不同颜色

[英]Xcode 8: Interface builder shows different color that set

Take a look at the picture below: 看看下面的图片:

在此输入图像描述

This is the same hex used in both places #28647B. 这是在两个地方使用的相同的十六进制#28647B。 The lower part is set from code and appears to reflects the color properly: 下部是从代码设置并显示正确反映颜色:

let proxy = UIPageControl.appearance()
proxy.pageIndicatorTintColor = UIColor.lightGray.withAlphaComponent(0.6)
proxy.currentPageIndicatorTintColor = UIColor.white
proxy.backgroundColor = UIColor(red: 40.0/255.0, green: 100.0/255.0, blue: 123.0/255.0, alpha: 1.0)

The upper part is set in interface builder. 上部在界面构建器中设置。

I checked all other layers, opacity parameters etc and found nothing that can change the way this color look. 我检查了所有其他图层,不透明度参数等,发现没有什么可以改变这种颜色的样子。

Now interesting part, I inspected both colors using HexColor mac app, this is the result: 现在有趣的是,我使用HexColor mac app检查了两种颜色,这是结果:

for upper part: 上半部分:

在此输入图像描述

Not sure what does it mean that RGB factors vary from the correct ones, but result is correct 不确定RGB因素与正确因素有什么不同,但结果是正确的

Now, time to inspect the lower part: 现在,时间检查下半部分:

在此输入图像描述

This time RGB looks good but results is different. 这次RGB看起来不错但结果却不同。

Now it's the best part: 现在它是最好的部分:

When I set the background color from code as I did in appearance proxy, it works fine. 当我在代码中设置背景颜色时,就像我在外观代理中所做的那样,它工作正常。 Is something interface builder speciffic that changes the visible shade of background color? 界面构建器是否具有特定的更改背景颜色的可见阴影? How can one rely on colors set in Interface Builder? 如何依赖Interface Builder中设置的颜色?

Same problem in my projects, I solved this issue choosing "Device RGB" and not "Generic RGB". 在我的项目中同样的问题,我选择“设备RGB”而不是“通用RGB”解决了这个问题。 Some. 一些。 time the color not change , move opacity and the color will set. 时间颜色不变,移动不透明度,颜色将设置。 see the image: 看图像:

在此输入图像描述

If you make an Asset Catalog, and add your colours in there, you can enter them as. 如果您制作资产目录,并在其中添加颜色,则可以输入它们。

Devices: Universal Content: sRGB Input Method: 8-bit Hexadecimal 设备:通用内容:sRGB输入法:8位十六进制

Add all your app colours in this way, and reference them by their Asset Catalog names, and all Hex Values will be preserved and displayed correctly. 以这种方式添加所有应用程序颜色,并通过其资产目录名称引用它们,并且将保留所有十六进制值并正确显示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM