I am struggling with loading an image to Image. I am making an MacOS app which is slightly different than for iOS.
I searched Internet however I found only several responses how to make it in iOS.
Please check the code:
import SwiftUI
struct ContentView: View {
let myUrl = URL(fileURLWithPath: "/Users/codegrinder/Documents/turtlerock.jpg")
init() {
//TODO Do something with the myUrl which is valid (not nil)
}
var body: some View {
Image("turtlerock")
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment:.center)
//I need to put the param to Image what I want to load an image from myUrl
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…