HostingController

@available(iOS 13.0, *)
open class HostingController : UIHostingController<AnyView>

SwiftUI控制器包装类,可将View事件用delegate代理到VC

Controller在MVVM中也为View的角色,可持有ViewModel,负责生命周期和界面跳转

Lifecyecle

  • Undocumented

    Declaration

    Swift

    public init()
  • Declaration

    Swift

    @MainActor
    required dynamic public init?(coder aDecoder: NSCoder)

Setup

  • 初始化导航栏,子类重写

    Declaration

    Swift

    open func setupNavbar()
  • 初始化子视图,子类重写,可结合StateView实现状态机

    Declaration

    Swift

    open func setupSubviews()