我有一组图像 URL(全部来自存储,而不是互联网)。如何显示图像本身? 简化代码:
@Binding var files:[URL]//Array of image URLs taken from an NSOpenPanel instance
Form{
if files.count>0{
Image(files[0].path)//Problem
}
}
答案 0 :(得分:1)
你说 NSOpenPanel
,所以我在这里假设我们不需要担心等待通过网络加载图像:
if let nsImage = NSImage(contentsOf: url) {
Image(nsImage: nsImage)
}