🌀Image(playground:)

Swift Playground for iPad 內使用:

#imageLiteral(resourceName: imgName)

目前得到的圖檔型別還是 UIImage,所以必須利用下面的方式再轉一手。

import SwiftUI

// usage: `Image(playground: "hokaido.png")`
extension Image {
    public init(playground imgName: String) {
        self.init(uiImage: #imageLiteral(resourceName: imgName))
    }
}

Last updated

Was this helpful?