简体   繁体   中英

How to use Image Literal in Xcode 13

The most used feature is missing in Xcode 13

Image Literal

#imageLiteral()

these commands do not seem to be working. A similar change has happened for Color Literals as well.

I used

UIImage(imageLiteralResourceName: "image_asset_name")

and it works perfectly fine on XCode 13.2.1

输入 Who.What = #imageLiteral( 目前它是这样工作的。

不过谢谢你的帮助,我试过 UIImageview(named:"imageName")

I came up with a workaround

Create code snippets for color literal and image literal like below

Color

#colorLiteral()

颜色文字

And add completion shortcut as you want, Example: colorLiteral . Do same for Image literal

Image

#imageLiteral()

图像文字

And add completion shortcut as you want. Call those completion shortcuts in your code to get color and image literals.

颜色文字 图像文字

There is no longer Image Literate :(

You may try:

Who.What = UIImage(named: "catImage")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM