netsplatter
netsplatter

Reputation: 729

How to completely disable content highlighting for NavigationLink in SwiftUI?

        NavigationLink(destination: DetailView()) {
            Image(systemName: "cloud.heavyrain")
                .foregroundColor(Color.accentColor)
                .font(.system(size: 66, weight: .regular))
        }
        .buttonStyle(PlainButtonStyle())

In this example .buttonStyle(PlainButtonStyle()) modifier changes highlighting to very mild, but still visible effect.

Upvotes: 6

Views: 1904

Answers (1)

netsplatter
netsplatter

Reputation: 729

I came up with quite simple solution by creating a custom ButtonStyle without any modifiers in it:

struct EmptyButtonStyle: ButtonStyle {
    func makeBody(configuration: Self.Configuration) -> some View {
        configuration.label
    }
}

Upvotes: 21

Related Questions