如何在 Xcode 13 中使用图像文字

Raj*_*esh 28 xcode swift xcode13

Xcode 13 中缺少最常用的功能

图像文字

#imageLiteral()

这些命令似乎不起作用。颜色文字也发生了类似的变化。

小智 30

不再有图像文字:(

您可以尝试:

Who.What = UIImage(named: "catImage")
Run Code Online (Sandbox Code Playgroud)

  • 这比 #imageLiteral( 更简单,因为弹出选择器有时不起作用 (2认同)

Sur*_*evi 17

我想出了一个解决方法

为颜色文字和图像文字创建代码片段,如下所示

颜色

#colorLiteral()
Run Code Online (Sandbox Code Playgroud)

颜色文字

并根据需要添加完成快捷方式,示例:colorLiteral。对图像文字执行相同操作

图像

#imageLiteral()
Run Code Online (Sandbox Code Playgroud)

图像文字

并根据需要添加完成快捷方式。在代码中调用这些完成快捷方式来获取colorimage文字。

颜色文字 图像文字


小智 11

输入 Who.What = #imageLiteral( 目前它的工作原理如下。


shi*_*hir 7

我用了

UIImage(imageLiteralResourceName: "image_asset_name")

它在 XCode 13.2.1 上运行得很好