How to use systemGrayXColor in InterfaceBuilder?

前端 未结 2 1778
离开以前
离开以前 2021-01-15 01:54

In the Apple documentation under Adaptable Gray Colors I can read that they provide, among other colors:

  • systemGray2Color
  • systemGray3Color
  • sy
相关标签:
2条回答
  • 2021-01-15 01:56

    Ok, I could use the color by manually changing it in the underlaying XML.

    I changed the systemColor attribute of the color XML element.

    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.

    Resulting in:

    As mentiond in the question already there are the following shades of gray supported:

    • systemGray2Color
    • systemGray3Color
    • systemGray4Color
    • systemGray5Color
    • systemGray6Color

    My tests revealed if you misspell the color or use a not supported shade the Interface Builder will show black color instead.

    This was done using Xcode Version 11.2.1.

    0 讨论(0)
  • 2021-01-15 02:04

    This is a known bug in Xcode and will be fixed in the upcoming Xcode 11.4:

    Added dynamic system gray colors to inspector color pickers. (55403376) (FB7281404)

    0 讨论(0)
提交回复
热议问题