本文介绍了如何在InterfaceBuilder中使用systemGrayXColor?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自适应灰色"下的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.

  1. 在界面生成器"中,将背景色"设置为System Gray Color
  2. 在Xcode中,右键单击Storyboard/Xib文件,然后使用Open as-> Source Code条目
  3. 搜索要更改的视图,然后在该视图内搜索color XML元素
  4. 将颜色系统灰色2的systemColor="systemGrayColor"更改为systemColor="systemGray2Color".
  5. 使用步骤2并再次在Interface Builder中打开Storyboard/Xib文件,然后保存该文件,以使同一XML键的redgreenblue颜色属性也得到调整.
  1. In the Interface Builder set the Background color to System Gray Color
  2. In the Xcode right click on the Storyboard/Xib file and use Open as -> Source Code entry
  3. Search the View you want to change and within that view the color XML element
  4. Change the systemColor="systemGrayColor" to systemColor="systemGray2Color" for color system gray 2.
  5. Use step 2 and open the Storyboard/Xib file in the Interface Builder again and Save the file so the red, green and blue 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 17:38