URLImage
AsyncImage
import SwiftUI
import URLImage
struct TestView: View {
var body: some View {
if #available(iOS 15.0, *) {
AsyncImage(url: URL(string: "https://velog.velcdn.com/images/fiddich/post/fecaabfe-eae6-4da0-92de-05a6156bc288/image.png")) { image in
image
.resizable()
.aspectRatio(contentMode: .fill)
} placeholder: {
ProgressView()
}
.frame(width: 100, height: 100)
}
else {
URLImage(URL(string: "https://velog.velcdn.com/images/fiddich/post/fecaabfe-eae6-4da0-92de-05a6156bc288/image.png")!) {
EmptyView()
} inProgress: { progress in
ProgressView()
} failure: { error, retry in
VStack {
Text(error.localizedDescription)
Button("Retry", action: retry)
}
} content: { image in
image
.resizable()
.aspectRatio(contentMode: .fill)
}
.frame(width: 100, height: 100)
}
}
}
