如何在 Xcode 故事板颜色选择器中添加自定义颜色?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36474035/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add custom color in Xcode storyboard color picker?
提问by Saood
回答by Mahendra
You can add custom color as folow
您可以添加自定义颜色如下
- Select color property(Background color, text color, etc.). A popup is shown from that select "other" option.
- 选择颜色属性(背景颜色、文本颜色等)。从该选择的“其他”选项中显示一个弹出窗口。
- A color picker will be opened. Here you can set your custom color by RGB/Hex Code and you can set opacity.
- 将打开一个颜色选择器。在这里,您可以通过 RGB/十六进制代码设置自定义颜色,还可以设置不透明度。
The color will be applied and visible under "Recently Used Colors". This is how you can add custom colors but as far as I know you can't add colors in that default list.
颜色将在“最近使用的颜色”下应用并可见。这是您可以添加自定义颜色的方法,但据我所知,您无法在该默认列表中添加颜色。
回答by SeNeO
Create a new palette by clicking "New" here:
A new palette "Unnamed" will be created. You can rename that palette by clicking the cog again and choosing "Rename..." Then, you'll need to click on the objects you want to capture the color of, and drag the color of those objects into the color chip area:
将创建一个新的调色板“未命名”。您可以通过再次单击齿轮并选择“重命名...”来重命名该调色板,然后,您需要单击要捕获其颜色的对象,并将这些对象的颜色拖到颜色芯片区域中:
Once you've captured the color, you can even rename it something that indicates where it's normally used, providing more information to the recipient than just the color.
捕获颜色后,您甚至可以将其重命名为指示其通常使用位置的名称,从而为接收者提供更多信息,而不仅仅是颜色。
回答by Matt
As of Xcode 9 you can add colors to your asset catalog. Open your asset catalog, click the + and add a color set. Click on the color that was created and you can name it and set the color using the inspector. Thereafter that color shows up in storyboard color chooses in the area called Named Colors.
从 Xcode 9 开始,您可以向资产目录添加颜色。打开您的资产目录,单击 + 并添加颜色集。单击创建的颜色,您可以命名它并使用检查器设置颜色。此后,该颜色显示在名为“命名颜色”的区域中的故事板颜色选择中。