How can I disable the highlighted color when a button is tapped?
Now when I tap it, it gets gray and the action gets called, but I want to disable it. Is it possible at the moment?
PresentationLink(destination: NextView()) {
....
}
How can I disable the highlighted color when a button is tapped?
Now when I tap it, it gets gray and the action gets called, but I want to disable it. Is it possible at the moment?
PresentationLink(destination: NextView()) {
....
}
PresentationView
does not seem to have a way of styling the button, and I doubt it'll ever will. However, there are other methods to present a view. Below you have an example that will avoid the effect. It is a little more verbose, but it will serve your purpose.
As of beta3, modals seem to have a bug, and the onDismiss method is never called. So it is hard to reset the isPresented variable properly. In the meantime, I use a workaround for that. Check this answer for that: https://stackoverflow.com/a/56939555/7786555
struct ContentView : View {
@State var isPresented = false
var body: some View {
VStack(spacing: 30) {
// Option #1, with blink
PresentationLink(destination: NextView(), label: {
Text("Click to show")
})
// Option #2, without blink
Text("Click to show").color(.blue).tapAction { self.isPresented = true }
.presentation(isPresented ? Modal(NextView()) : nil)
}
}
}
struct NextView: View {
var body: some View {
Text("aloha!")
}
}