故事板中的颜色与UIColor不匹配 [英] Color in storyboard not matching UIColor

查看:181
本文介绍了故事板中的颜色与UIColor不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在代码中定义颜色为

[UIColor colorWithHue:32.0/360.0 saturation:0.88 brightness:0.97 alpha:1]

如果我尝试在故事板中设置相同的颜色,那么在运行App时它会略微与代码中定义的颜色不同。如果我将颜色拖到上颚,然后选择不同的颜色并再次选择上颚,HSB值略有不同。它似乎是在界面构建器中捕捉到不同的(RGB?)颜色。

If I try to set the same color in storyboard, when running the App it is a slightly different colour to the one defined in code. If I drag the color to the palate then select a different color and select the palate one again, the HSB values are slightly different. It seems it is snapping to a different (RGB?) color in interface builder.

推荐答案

Xcode 8 +,iOS 10 +

我最近遇到了这个问题,所有发布的答案都没有。事实证明,随着iOS 10 SDK的发布, UIColor 初始化器 init(红色:绿色:蓝色:alpha:)现在使用扩展的sRGB范围,因此您必须在故事板上配置颜色值时进行相应设置。

I recently faced this problem and none of the posted answers did it. It turns out that with the release of iOS 10 SDK, the UIColor initializer init(red:green:blue:alpha:) now uses the extended sRGB range, so you have to set accordingly when configuring your color values on the Storyboard.

请参阅Apple的文档: https://developer.apple.com/ reference / uikit / uicolor / 1621925-init

See Apple's documentation: https://developer.apple.com/reference/uikit/uicolor/1621925-init

这篇关于故事板中的颜色与UIColor不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆