HomeiOS DevelopmentTextual content shouldn't be seen when the button is in disabled state

Textual content shouldn’t be seen when the button is in disabled state


I am encountering a bizarre habits on iOS 26. I’ve a easy Liquid Glass button on a view.

struct ContentView: View {
    @State personal var isSheetVisible: Bool = false
    @State personal var textual content: String = ""
    
    
    var physique: some View {
        VStack {
            Button {
                isSheetVisible.toggle()
            } label: {
                Textual content("Present Sheet")
                    .font(.system(measurement: 20))
                    .fontWeight(.semibold)
            }
            .buttonStyle(.glassProminent)
            .controlSize(.massive)
            .buttonSizing(.versatile)
            .tint(.crimson)
            .body(width: 340)
            .disabled(textual content.isEmpty)
        }
        .padding()
        .sheet(isPresented: $isSheetVisible) {
            OverlaySheet()
        }
    }
}

This works nice. And if I disable the button like this .disabled(textual content.isEmpty), the opacity of the textual content on the button is lowered somewhat however nonetheless stays clearly seen.

Textual content shouldn’t be seen when the button is in disabled state

Subsequent, I need to present a sheet over this view and I’ve an analogous button in that sheet as effectively.

struct OverlaySheet: View {
    @Setting(.dismiss) personal var dismiss
    @State personal var textual content: String = ""
    
    
    var physique: some View {
        VStack {
            Button {
                dismiss()
            } label: {
                Textual content("Dismiss")
                    .font(.system(measurement: 20))
                    .fontWeight(.semibold)
            }
            .buttonStyle(.glassProminent)
            .controlSize(.massive)
            .buttonSizing(.versatile)
            .tint(.crimson)
            .body(width: 340)
            .disabled(textual content.isEmpty)
        }
        .padding()
        .presentationDetents([.fraction(0.5)])
    }
}

That is the place it will get bizarre. When the button within the sheet shouldn’t be disabled, the button textual content seems. But when I disable the button much like what I did earlier than, the textual content barely seen.

Screenshots showing the button is normal and disabled state

Any concept what that is taking place?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments