ViewControllerType
public struct ViewControllerType : IntrospectableViewType
An abstract representation of the receiving SwiftUI view’s view controller, or the closest ancestor view controller if missing.
struct ContentView: View {
var body: some View {
NavigationView {
Text("Root").frame(maxWidth: .infinity, maxHeight: .infinity).background(Color.red)
.introspect(.viewController, on: .iOS(.v13, .v14, .v15, .v16, .v17)) {
print(type(of: $0)) // some subclass of UIHostingController
}
}
.navigationViewStyle(.stack)
.introspect(.viewController, on: .iOS(.v13, .v14, .v15, .v16, .v17)) {
print(type(of: $0)) // UINavigationController
}
}
}
-
Declaration
Swift
public var scope: IntrospectionScope { get }