ViewControllerType
@MainActor
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(.all)) {
print(type(of: $0)) // some subclass of UIHostingController
}
}
.navigationViewStyle(.stack)
.introspect(.viewController, on: .iOS(.all)) {
print(type(of: $0)) // UINavigationController
}
}
}
-
Declaration
Swift
@MainActor public var scope: IntrospectionScope { get }