init<I, P>(url: URL?, scale: CGFloat, content: (Image) -> I, placeholder: () -> P)
The URL of the image to display.
Availability 有効性
Technology
url
The URL of the image to display.
scale
The scale to use for the image. The default is 1
. Set a different value when loading images designed for higher resolution displays. For example, set a value of 2
for an image that you would name with the @2x
suffix if stored in a file on disk.
Until the image loads, SwiftUI displays a default placeholder. When the load operation completes successfully, SwiftUI updates the view to show the loaded image. If the operation fails, SwiftUI continues to display the placeholder. The following example loads and displays an icon from an example server:
AsyncImage(url: URL(string: "https://example.com/icon.png"))
If you want to customize the placeholder or apply image-specific modifiers — like resizable(cap
— to the loaded image, use the init(url:
initializer instead.
init<I, P>(url: URL?, scale: CGFloat, content: (Image) -> I, placeholder: () -> P)