问题描述
在自适应灰色"下的Apple文档可以读取它们提供的颜色,以及其他颜色:
In the Apple documentation under Adaptable Gray Colors I can read that they provide, among other colors:
- systemGray2Color
- systemGray3Color
- systemGray4Color
- systemGray5Color
- systemGray6Color
在Xcode的界面生成器(版本11.2.1)中,我可以看到 systemGrayColor ,但没有其他灰色阴影:
In the Interface Builder of Xcode (Version 11.2.1) I can see systemGrayColor but non of the other shades of gray:
如何在Interface Builder中设置其他系统灰色?
How do I set those other system gray colors in the Interface Builder?
推荐答案
好,我可以通过在底层XML中手动更改颜色来使用颜色.
Ok, I could use the color by manually changing it in the underlaying XML.
我更改了color
XML元素的systemColor
属性.
I changed the systemColor
attribute of the color
XML element.
- 在界面生成器"中,将背景色"设置为
System Gray Color
- 在Xcode中,右键单击Storyboard/Xib文件,然后使用
Open as
->Source Code
条目 - 搜索要更改的视图,然后在该视图内搜索
color
XML元素 - 将颜色系统灰色2的
systemColor="systemGrayColor"
更改为systemColor="systemGray2Color"
. - 使用步骤2并再次在Interface Builder中打开Storyboard/Xib文件,然后保存该文件,以使同一XML键的
red
,green
和blue
颜色属性也得到调整.
- In the Interface Builder set the Background color to
System Gray Color
- In the Xcode right click on the Storyboard/Xib file and use
Open as
->Source Code
entry - Search the View you want to change and within that view the
color
XML element - Change the
systemColor="systemGrayColor"
tosystemColor="systemGray2Color"
for color system gray 2. - Use step 2 and open the Storyboard/Xib file in the Interface Builder again and Save the file so the
red
,green
andblue
color attributes of the same XML key also gets adjusted.
结果:
问题中已经提到,支持以下灰色阴影:
As mentiond in the question already there are the following shades of gray supported:
- systemGray2Color
- systemGray3Color
- systemGray4Color
- systemGray5Color
- systemGray6Color
我的测试表明,如果您拼错了颜色或使用了不受支持的阴影,Interface Builder将显示黑色.
My tests revealed if you misspell the color or use a not supported shade the Interface Builder will show black color instead.
这是使用Xcode版本11.2.1完成的.
This was done using Xcode Version 11.2.1.
这篇关于如何在InterfaceBuilder中使用systemGrayXColor?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!