SwiftUI Views Defined in Other Frameworks

Use SwiftUI views that other Apple frameworks provide.

Overview 概要

To access SwiftUI views defined in another framework, import both SwiftUI and the other framework into the file where you use the view. You can find the framework to import by looking at the availability information on the view’s documentation page. For example, to use the Map view in your app, import both SwiftUI and MapKit:


import SwiftUI
import MapKit


struct MyMapView: View {
    // Center the map on Joshua Tree National Park.
    @State private var region = MKCoordinateRegion(
            center: CLLocationCoordinate2D(latitude: 34.011_286, longitude: -116.166_868),
            span: MKCoordinateSpan(latitudeDelta: 0.2, longitudeDelta: 0.2)
        )


    var body: some View {
        Map(coordinateRegion: $region)
    }
}

Topics 話題

Authorization and Authentication

Graphics

Location

Media

See Also 参照

Framework Integration フレームワーク統合