xcode 如何在 Interface Builder 中输入 RGB 值?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2565008/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:20:38  来源:igfitidea点击:

How do I enter RGB values into Interface Builder?

iphonecocoa-touchxcodeuser-interfaceinterface-builder

提问by Sheehan Alam

How can I enter RGB or Hex color values for backgrounds in Interface Builder? I can select predefined colors but I would like to manually enter in RGB values. Where can I do this?

如何在 Interface Builder 中为背景输入 RGB 或 Hex 颜色值?我可以选择预定义的颜色,但我想手动输入 RGB 值。我在哪里可以这样做?

回答by Tyler

How to choose a color by RGB in Interface Builder.

如何在 Interface Builder 中通过 RGB 选择颜色。

Click on the color slider icon, and then choose "RGB Sliders" from the drop-down list.

单击颜色滑块图标,然后从下拉列表中选择“RGB 滑块”。

You can also use the magnifying-glass as a color picker to pick up an exact color from anywhere on the screen; also see @ken's excellent comment below clarifying how colorspaces work with the magnifying glass.

您还可以将放大镜用作颜色选择器,从屏幕上的任何位置选取准确的颜色;另请参阅下面@ken 的精彩评论,其中阐明了色彩空间如何与放大镜配合使用。

回答by Zack Morris

Although Tyler's response answers the question, you may encounter issues using the picker because it uses the display's colorspace (as clarified by Ken).

尽管 Tyler 的回答回答了这个问题,但您在使用选择器时可能会遇到问题,因为它使用了显示器的色彩空间(如 Ken 所述)。

If you want to match RGB values between Photoshop and Xcode exactly(without conversion between colorspaces) then you need to save your images in generic RGB and enter any dropper values using the generic RGB colorspace.

如果您想在 Photoshop 和 Xcode 之间精确匹配 RGB 值(无需在颜色空间之间进行转换),那么您需要将图像保存为通用 RGB 并使用通用 RGB 颜色空间输入任何滴管值。

  • When you choose "Save for Web & Devices" from Photoshop, uncheck the "Convert to sRGB" box.
  • 当您从 Photoshop 中选择“保存为 Web 和设备”时,请取消选中“转换为 sRGB”框。

enter image description here

在此处输入图片说明

  • In Xcode, click the colorspace popup in the color picker and choose "Generic RGB", then enter the red, green and blue values from Photoshop, NOT THE HEX VALUEas this reverts back to the sRGB colorspace for some reason (be careful not to tab to the hex field either, as that also changes the colorspace to sRGB).
  • 在 Xcode 中,单击颜色选择器中的颜色空间弹出窗口并选择“通用 RGB”,然后从 Photoshop 中输入红色、绿色和蓝色值,而不是十六进制值,因为由于某种原因,这会恢复为 sRGB 颜色空间(注意不要选项卡到十六进制字段,因为这也会将色彩空间更改为 sRGB)。

enter image description here

在此处输入图片说明

More info here, including how to match screenshots.

更多信息在这里,包括如何搭配截图。

回答by Ken

It sounds like you're unfamiliar with the Mac OS X color panel. Click the tabs along the top of the color panel window to choose other pickers. Pickers are also plugins, so it's possible to add new UI for color selection. See, for example, developer color picker.

听起来您对 Mac OS X 颜色面板不熟悉。单击颜色面板窗口顶部的选项卡以选择其他选择器。选择器也是插件,因此可以为颜色选择添加新的 UI。例如,请参阅开发人员颜色选择器

回答by Philip Borges

I know this is an old question, but I needed to find out the answer to this very same question today and it got me on the right track. The color picker from panic.com did install correctly but the hexadecimal option from the drop down menu in the color picker always sets it to RGB. So no good. Instead I found this:

我知道这是一个老问题,但我今天需要找出这个问题的答案,这让我走上了正确的轨道。来自 panic.com 的颜色选择器确实安装正确,但颜色选择器下拉菜单中的十六进制选项总是将其设置为 RGB。所以没有好处。相反,我发现了这个:

http://wafflesoftware.net/hexpicker/

http://wafflesoftware.net/hexpicker/

That shows the hexadecimal value and it works fully on Xcode 5.0.1 and Mavericks.

这显示了十六进制值,它完全适用于 Xcode 5.0.1 和 Mavericks。

回答by Chandan Shetty SP

enter image description here

在此处输入图片说明

Check the above snap, in that go to Colors Tray, select the second button(RGB sliders(rectangle image) - which is placed next to circle on the top of the tray). In that you can enter RGB values.

检查上面的快照,在颜色托盘中,选择第二个按钮(RGB 滑块(矩形图像) - 位于托盘顶部的圆圈旁边)。您可以在其中输入 RGB 值。