UIViewController

public extension UIViewController
  • Функция добавляет View из SwiftUI в качестве дочерней для UIView.

    struct ExampleView: View {
       var body: some View {
           Text("Hello world")
       }
    }
    
    let controller = UIViewController()
    controller.addSubSwiftUIView(ExampleView(), to: controller.view)
    

    Declaration

    Swift

    func addSubSwiftUIView<Content>(_ swiftUIView: Content, to view: UIView) where Content : View

    Parameters

    swiftUIView

    View из SwiftUI, которая добавляется в качестве дочерней вью .

    view

    UIView родительская, в которую будет добавлена swiftUIView .