Xcode 10 - image literals no longer available

后端 未结 9 2068
甜味超标
甜味超标 2020-12-08 03:46

Xcode 10 Release Notes: \"Code Completion for Swift image literals has been removed in Xcode 10\"

So it\'s not a bug that I couldn\'t ad

相关标签:
9条回答
  • 2020-12-08 04:13

    TIP: To fix three resolutions after add a literal image in code.
    1. Remove another, keep only one image
    2. Comment your line code with literal image, then will appear literal image in code, like: #imageLiteral(resourceName: "image@2x.png"
    3. in resourceName value, remove @2x and file extension, like .png, keep only image name: #imageLiteral(resourceName: "image")
    4. Uncomment! Image will be showed in code.

    0 讨论(0)
  • 2020-12-08 04:19

    You can use Media Library in Xcode to add image literal to your code:

    And then choose image from library and drag&drop it to your code

    It will create image literal

    0 讨论(0)
  • 2020-12-08 04:25

    In Xcode 11, the media library is now under View > Show Library (SHIFT+CMD+L).

    0 讨论(0)
提交回复
热议问题