How to completely disable content highlighting for NavigationLink in SwiftUI?
Asked Answered
D

1

6
        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.

Dualpurpose answered 1/2, 2022 at 22:24 Comment(0)
D
20

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
    }
}
Dualpurpose answered 1/2, 2022 at 22:24 Comment(2)
You know what? You really are a hero!! Such a beautiful solution! And so many ppl looking for this ...Employee
Thanks you are the god I have been looking for..Hautemarne

© 2022 - 2025 — McMap. All rights reserved.