Structures
The following structures are available globally.
-
The
NSInterfaceViewstruct helps you to use AppKit NSView or its derived class in project using SwiftUI.NSInterfaceViewis a type that represents part of your app’s user interface using AppKit and provides modifiers that you use to configure views.You create custom views by declaring types that conform to the
Viewprotocol. Implement the requiredView/body-swift.propertycomputed property to provide the content for your custom view. Then you can present your AppKitt View by usingNSInterfaceView(MyView()), as follows.struct MyView: View { var body: some View { NSInterfaceView(MyView()) } }The
Viewprotocol provides a large set of modifiers, defined as protocol methods with default implementations, that you use to position and configure views in the layout of your app. Modifiers typically work by wrapping the view instance on which you call them in another view with the specified characteristics. For example, adding theView/opacity(_:)modifier to a interface view returns a new view with some amount of transparency:NSInterfaceView(MyView()) .opacity(0.5) // Display partially transparent interface view.It is recommended to use
ZStackwithNSInterfaceView, as follows.ZStack { NSInterfaceView(MyView()) MySwiftUIView() }A wrapper that you use to integrate an AppKit view into your SwiftUI view hierarchy.
Use an
NSInterfaceViewinstance to create and manage an doc://com.apple.documentation/documentation/AppKit/NSView object in your SwiftUI interface. Adopt this protocol in one of your app’s custom instances, and use its methods to create, update, and tear down your view. The creation and update processes parallel the behavior of SwiftUI views, and you use them to configure your view with your app’s current state information. Use the teardown process to remove your view cleanly from your SwiftUI. For example, you might use the teardown process to notify other objects that the view is disappearing.To add your view into your SwiftUI interface, create your
NSInterfaceViewinstance and add it to your SwiftUI interface. The system calls the methods of your representable instance at appropriate times to create and update the view. The following example shows the inclusion of aNSInterfaceViewin the view hierarchy.struct ContentView: View { var body: some View { ZStack { Text("Global Sales") NSInterfaceView(MyNSView()) } } }The system doesn’t automatically communicate changes occurring within your view controller to other parts of your SwiftUI interface. When you want your view controller to coordinate with other SwiftUI views, you must provide a
See moreNSViewControllerRepresentable/Coordinatorobject to facilitate those interactions. For example, you use a coordinator to forward target-action and delegate messages from your view controller to any SwiftUI views.Declaration
Swift
public struct NSInterfaceView : NSViewRepresentable
-
The
NSInterfaceViewControllerstruct helps you to use AppKit NSViewController or its derived class in project using SwiftUI.NSInterfaceViewControlleris a type that represents part of your app’s user interface using AppKit and provides modifiers that you use to configure views.You create custom views by declaring types that conform to the
Viewprotocol. Implement the requiredView/body-swift.propertycomputed property to provide the content for your custom view. Then you can present your AppKit ViewController View by usingNSInterfaceViewController(MyViewController()), as follows.struct MyView: View { var body: some View { NSInterfaceViewController(MyViewController()) } }The
Viewprotocol provides a large set of modifiers, defined as protocol methods with default implementations, that you use to position and configure views in the layout of your app. Modifiers typically work by wrapping the view instance on which you call them in another view with the specified characteristics. For example, adding theView/opacity(_:)modifier to a interface view returns a new view with some amount of transparency:NSInterfaceViewController(MyViewController()) .opacity(0.5) // Display partially transparent interface view.It is recommended to use
ZStackwithNSInterfaceViewController, as follows.ZStack { NSInterfaceViewController(MyViewController()) MySwiftUIView() }A wrapper that you use to integrate an AppKit view controller into your SwiftUI interface.
Use an
NSViewControllerRepresentableinstance to create and manage an doc://com.apple.documentation/documentation/AppKit/NSViewController object in your SwiftUI interface. Adopt this protocol in one of your app’s custom instances, and use its methods to create, update, and tear down your view controller. The creation and update processes parallel the behavior of SwiftUI views, and you use them to configure your view controller with your app’s current state information. Use the teardown process to remove your view controller cleanly from your SwiftUI. For example, you might use the teardown process to notify other objects that the view controller is disappearing.To add your view controller into your SwiftUI interface, create your
NSViewControllerRepresentableinstance and add it to your SwiftUI interface. The system calls the methods of your custom instance at appropriate times.The system doesn’t automatically communicate changes occurring within your view controller to other parts of your SwiftUI interface. When you want your view controller to coordinate with other SwiftUI views, you must provide a
See moreNSViewControllerRepresentable/Coordinatorinstance to facilitate those interactions. For example, you use a coordinator to forward target-action and delegate messages from your view controller to any SwiftUI views.Declaration
Swift
public struct NSInterfaceViewController : NSViewControllerRepresentable
-
The
InterfaceViewstruct helps you to use UIKit UIView or its derived class in project using SwiftUI.InterfaceViewis a type that represents part of your app’s user interface using UIKit and provides modifiers that you use to configure views.You create custom views by declaring types that conform to the
Viewprotocol. Implement the requiredView/body-swift.propertycomputed property to provide the content for your custom view. Then you can present your UIKit View by usingInterfaceView(MyView()), as follows.struct MyView: View { var body: some View { InterfaceView(MyView()) } }The
Viewprotocol provides a large set of modifiers, defined as protocol methods with default implementations, that you use to position and configure views in the layout of your app. Modifiers typically work by wrapping the view instance on which you call them in another view with the specified characteristics. For example, adding theView/opacity(_:)modifier to a interface view returns a new view with some amount of transparency:InterfaceView(MyView()) .opacity(0.5) // Display partially transparent interface view.It is recommended to use
ZStackwithInterfaceView, as follows.ZStack { InterfaceView(MyView()) MySwiftUIView() }Use an
InterfaceViewinstance to create and manage a doc://com.apple.documentation/documentation/UIKit/UIViewController object in your SwiftUI interface. Use this struct in one of your app’s custom instances, and use its methods to create, update, and tear down your view controller. The creation and update processes parallel the behavior of SwiftUI views, and you use them to configure your view controller with your app’s current state information. Use the teardown process to remove your view controller cleanly from your SwiftUI. For example, you might use the teardown process to notify other objects that the view controller is disappearing.To add your view controller into your SwiftUI interface, create your
InterfaceViewinstance and add it to your SwiftUI interface. The system calls the methods of your custom instance at appropriate times.The system doesn’t automatically communicate changes occurring within your view controller to other parts of your SwiftUI interface. When you want your view controller to coordinate with other SwiftUI views, you must provide a
See moreNSViewControllerRepresentable/Coordinatorinstance to facilitate those interactions. For example, you use a coordinator to forward target-action and delegate messages from your view controller to any SwiftUI views.
-
The
InterfaceViewControllerstruct helps you to use UIKit UIViewController or its derived class in project using SwiftUI.InterfaceViewControlleris a type that represents part of your app’s user interface using UIKit and provides modifiers that you use to configure views.You create custom views by declaring types that conform to the
Viewprotocol. Implement the requiredView/body-swift.propertycomputed property to provide the content for your custom view. Then you can present your UIKit ViewController View by usingInterfaceViewController(MyViewController()), as follows.struct MyView: View { var body: some View { InterfaceViewController(MyViewController()) } }The
Viewprotocol provides a large set of modifiers, defined as protocol methods with default implementations, that you use to position and configure views in the layout of your app. Modifiers typically work by wrapping the view instance on which you call them in another view with the specified characteristics. For example, adding theView/opacity(_:)modifier to a interface view returns a new view with some amount of transparency:InterfaceViewController(MyViewController()) .opacity(0.5) // Display partially transparent interface view.It is recommended to use
ZStackwithInterfaceViewController, as follows.ZStack { InterfaceViewController(MyViewController()) MySwiftUIView() }Use an
InterfaceViewControllerinstance to create and manage a doc://com.apple.documentation/documentation/UIKit/UIViewController object in your SwiftUI interface. Use this struct in one of your app’s custom instances, and use its methods to create, update, and tear down your view controller. The creation and update processes parallel the behavior of SwiftUI views, and you use them to configure your view controller with your app’s current state information. Use the teardown process to remove your view controller cleanly from your SwiftUI. For example, you might use the teardown process to notify other objects that the view controller is disappearing.To add your view controller into your SwiftUI interface, create your
InterfaceViewControllerinstance and add it to your SwiftUI interface. The system calls the methods of your custom instance at appropriate times.The system doesn’t automatically communicate changes occurring within your view controller to other parts of your SwiftUI interface. When you want your view controller to coordinate with other SwiftUI views, you must provide a
See moreNSViewControllerRepresentable/Coordinatorinstance to facilitate those interactions. For example, you use a coordinator to forward target-action and delegate messages from your view controller to any SwiftUI views.
-
The
WKInterfaceViewstruct helps you to use WatchKiit WKInterfaceObject or its derived class in project using SwiftUI.WKInterfaceViewis a type that represents part of your app’s user interface using WatchKit and provides modifiers that you use to configure views.You create custom views by declaring types that conform to the
Viewprotocol. Implement the requiredView/body-swift.propertycomputed property to provide the content for your custom view. Then you can present your WatchKit WKInterfaceObject by usingWKInterfaceView(MyWKInterfaceObject()), as follows.struct MyWKInterfaceObject: View { var body: some View { WKInterfaceView(MyWKInterfaceObject()) } }The
Viewprotocol provides a large set of modifiers, defined as protocol methods with default implementations, that you use to position and configure views in the layout of your app. Modifiers typically work by wrapping the view instance on which you call them in another view with the specified characteristics. For example, adding theView/opacity(_:)modifier to a interface view returns a new view with some amount of transparency:WKInterfaceView(MyWKInterfaceObject()) .opacity(0.5) // Display partially transparent interface view.It is recommended to use
ZStackwithWKInterfaceView, as follows.ZStack { WKInterfaceView(MyWKInterfaceObject()) MySwiftUIView() }A view that represents a WatchKit interface object.
Use a
WKInterfaceObjectRepresentableinstance to create and manage a doc://com.apple.documentation/documentation/WatchKit/WKInterfaceObject in your SwiftUI interface. Adopt this protocol in one of your app’s custom instances, and use its methods to create, update, and tear down your interface object. The creation and update processes parallel the behavior of SwiftUI views, and you use them to configure your interface object with your app’s current state information. Use the teardown process to remove your interface object cleanly from your SwiftUI. For example, you might use the teardown process to notify other parts of your app that the interface object is disappearing.To add your interface object into your SwiftUI interface, create your
UIViewRepresentableinstance and add it to your SwiftUI interface. The system calls the methods of your representable instance at appropriate times to create and update the interface object.The system doesn’t automatically communicate changes occurring within your interface object to other parts of your SwiftUI interface. When you want your interface object to coordinate with other SwiftUI views, you must provide a
See moreNSViewControllerRepresentable/Coordinatorinstance to facilitate those interactions. For example, you use a coordinator to forward target-action and delegate messages from your interface object to any SwiftUI views.
View on GitHub
Install in Dash
Structures Reference