Contents

labelsVisibility

The labels visibility set by Labelsvisibility(_:).

Declaration

var labelsVisibility: Visibility { get set }

Discussion

Read this environment value from within a view to obtain the preferred visibility for labels within the hierarchy. If you would like to dynamically hide the label of your custom view, make sure to include an accessibility label via the accessibilityLabel(content:) modifier as illustrated below:

@Environment(\.labelsVisibility)
private var labelsVisibility

var body: some View {
    VStack {
        QuizCardView()
        if labelsVisibility != .hidden {
            label
        }
    }
    .accessibilityLabel {
        label
    }
}

private var label: some View {
    Text("Quiz Card")
}

See Also

Hiding system elements