如何通过Xcode中的代码更改文本颜色
我正在尝试制作一个按钮来更改Xcode中名为如何通过Xcode中的代码更改文本颜色,xcode,cocoa,Xcode,Cocoa,我正在尝试制作一个按钮来更改Xcode中名为labelDisplay的标签中文本和阴影的颜色。我尝试在按钮的按下功能中使用以下代码: labelDisplay.textColor = UIColor(displayP3Red: 1, green: 1, blue: 1, alpha: 1) labelDisplay.shadowColor = UIColor(displayP3Red: 60, green: 60, blue: 60, alpha: 1) 在另一个按钮中:
labelDisplay
的标签中文本和阴影的颜色。我尝试在按钮的按下功能中使用以下代码:
labelDisplay.textColor = UIColor(displayP3Red: 1, green: 1, blue: 1, alpha: 1)
labelDisplay.shadowColor = UIColor(displayP3Red: 60, green: 60, blue: 60, alpha: 1)
在另一个按钮中:
labelDisplay.textColor = UIColor(displayP3Red: 183, green: 181, blue: 60, alpha: 1)
labelDisplay.shadowColor = UIColor(displayP3Red: 145, green: 143, blue: 52, alpha: 1)
我不知道为什么,但当我进入模拟器并按下其中任何一个按钮时,输出框中会出现以下错误:
2018-04-20 14:09:12.641080 HelloWorld_Brandon[2362:34953] [Graphics] UIColor created with component values far outside the expected range. Set a breakpoint on UIColorBreakForOutOfRangeColorComponents to debug. This message will only be logged once.
有人能帮我吗?您是否有意使用显示P3颜色空间 根据文档,无论哪种方式,参数都是“指定为0.0到1.0之间的值”,183比这大得多。尝试指定
0.71
或183.0/255.0