iPhone SwiftUI layouts

Explore SwiftUI APIs, components, and modifiers with interactive iPhone previews, Swift code, and Apple documentation. Compare every available orientation, appearance, and design.

AsyncImage

Custom Session Async URL Image

A modifier that adds a URL session for asynchronous images contained in the view to use when fetching image data.

Explore Custom Session Async URL Image on iPhone in portrait, with SwiftUI code and Apple API documentation.

let imageURL = URL(string: "https://exploreswiftui.com/images/cats.jpg")!
let imageSession: URLSession = {
    let configuration = URLSessionConfiguration.default
    configuration.httpAdditionalHeaders = [
        "X-Custom-Header": "CustomValue"
    ]

    return URLSession(configuration: configuration)
}()

var body: some View {
    AsyncImage(request: URLRequest(url: imageURL)) { image in
        image
    } placeholder: {
        ProgressView()
    }
    .asyncImageURLSession(imageSession)
}
iOS 27.0+ iPadOS 27.0+ macOS 27.0+ watchOS 27.0+ tvOS 27.0+ visionOS 27.0+

Every available iPhone screenshot for Custom Session Async URL Image.

1 views