文字(图像和颜色)在 Xcode 中不起作用

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

Literals (Images & Colors) don't work in Xcode

swiftxcode

提问by Badr

When I try using literals in a Playground, it shows me like this (doesn't show my image):

当我尝试在 Playground 中使用文字时,它显示我这样(不显示我的图像):

anotherExamplein above i add image or UIImage literal but doesn't show their contents.\

另一个例子在上面我添加了图像或 UIImage 文字但不显示它们的内容。\

and also this with colors (I can't even see colors):

还有这个颜色(我什至看不到颜色):

another example

另一个例子

回答by PGDev

When you type Color Literal, a white box appears. In order to set the required colour, tap on that white box to select the colour from Color Picker.

当您键入 时Color Literal,会white bo出现一个x。为了设置所需的颜色,点击那个白色框到select the colour from Color Picker

This is what it looks like:

这是它的样子:

enter image description here

在此处输入图片说明

回答by Badr

Make sure you add to the class import UIKit

确保您添加到班级 import UIKit