SwiftUIAdapter

@MainActor
public final class SwiftUIAdapter<Content> : SwiftUIAdaptable where Content : ViewDestinationInterfacing

Adapts a SwiftUI View for use inside a UIViewController, using a UIHostingController to present it within UIKit.

  • A SwiftUI View to display.

    Declaration

    Swift

    @MainActor
    public var view: Content
  • A reference to the parent of the hosting controller.

    Declaration

    Swift

    @MainActor
    weak public var parentController: UIViewController? { get set }
  • The hosting controller for the SwiftUI View.

    Declaration

    Swift

    @MainActor
    public var hostingController: UIHostingController<Content>
  • The initializer.

    Declaration

    Swift

    @MainActor
    public init(@ViewBuilder content: () -> Content, parent: UIViewController? = nil)

    Parameters

    content

    The SwiftUI View to adapt.

    parent

    A reference to the parent of the hosting controller.

  • Undocumented

    Declaration

    Swift

    @MainActor
    public func cleanupResources()