Contents

inspector(isPresented:content:)

Inserts an inspector at the applied position in the view hierarchy.

Declaration

nonisolated func inspector<V>(isPresented: Binding<Bool>, @ViewBuilder content: () -> V) -> some View where V : View

Parameters

  • isPresented:

    A binding to Bool controlling the presented state.

  • content:

    The inspector content.

Discussion

Apply this modifier to declare an inspector with a context-dependent presentation. For example, an inspector can present as a trailing column in a horizontally regular size class, but adapt to a sheet in a horizontally compact size class.

struct ShapeEditor: View {
    @State var presented: Bool = false
    var body: some View {
        MyEditorView()
            .inspector(isPresented: $presented) {
                TextTraitsInspectorView()
            }
    }
}

See Also

Presenting an inspector