ios - x.jpg 在 Xcode 编辑器中显示为一个框

标签 ios xcode

请原谅我的愚蠢问题!我是 iOS 的新手,这是我的愚蠢问题 - 当我尝试将图像设置为时,

img.image = image.jpg

screenshot image.jpg 在 xcode 编辑器中显示为一个框。为什么会这样?这样做是好的做法吗?

我正在使用 xcode 8.2.1。

谢谢!

最佳答案

一般情况下,您可以使用 UIImage(named:)

image = #imageLiteral(resourceName: "bow_s") // See the image below
image = UIImage(named: "bow_s")! // same with first

sample 1

sample 2

关于ios - x.jpg 在 Xcode 编辑器中显示为一个框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44666220/

相关文章:

iphone - 如何恢复所有那些好的旧 Xcode 功能?

ios - React native - 连接没有连接处理程序错误含义?

ios - 自定义字体在 IB 中设置时正确显示,但在以编程方式设置时不正确

ios - Int 在 UILabel 中没有达到 11

ios - 如何在特定时间点进行后台获取,比如午夜

iphone - 如何更改 AppleID 以检索配置文件

Xcode 6.3 没有助手结果

ios - react native : What is the difference between using Cocoapods and manually linking modules?

ios - 如何在 watchos 中使用 WCSessionUserInfoTransfer?

ios - GIT:如何从工作目录中 check out 所有文件?