case empty
No image is loaded.
case success(Image)
An image succesfully loaded.
case failure(Error)
An image failed to load with an error.
Availability 有効性
Technology
enum AsyncImagePhase
When you create an Async
instance with the init(url:
initializer, you define the appearance of the view using a content
closure. SwiftUI calls the closure with a phase value at different points during the load operation to indicate the current state. Use the phase to decide what to draw. For example, you can draw the loaded image if it exists, a view that indicates an error, or a placeholder:
AsyncImage(url: URL(string: "https://example.com/icon.png")) { phase in
if let image = phase.image {
image // Displays the loaded image.
} else if phase.error != nil {
Color.red // Indicates an error.
} else {
Color.blue // Acts as a placeholder.
}
}
case empty
case success(Image)
case failure(Error)
var image: Image?
var error: Error?
struct AsyncImage