Update the readme chapter of FAQ about NavigationLink as well, update the demo

This commit is contained in:
DreamPiggy 2019-11-16 21:11:30 +08:00
parent 72c604d4ce
commit babb23ba11
2 changed files with 15 additions and 1 deletions

View File

@ -141,6 +141,7 @@ struct ContentView: View {
Text((url as NSString).lastPathComponent)
}
}
.buttonStyle(PlainButtonStyle())
}
.onDelete { indexSet in
indexSet.forEach { index in

View File

@ -218,9 +218,15 @@ Button(action: {
}) {
WebImage(url: url)
}
// NavigationLink create Button implicitly
NavigationView {
NavigationLink(destination: Text("Detail view here")) {
WebImage(url: url)
}
}
```
Instead, you must override the `.buttonStyle` to use the plain style. Or you can use the `.onTapGesture` modifier for touch handling. See [How to disable the overlay color for images inside Button and NavigationLink](https://www.hackingwithswift.com/quick-start/swiftui/how-to-disable-the-overlay-color-for-images-inside-button-and-navigationlink)
Instead, you must override the `.buttonStyle` to use the plain style, or the `.renderingMode` to use original mode. You can also use the `.onTapGesture` modifier for touch handling. See [How to disable the overlay color for images inside Button and NavigationLink](https://www.hackingwithswift.com/quick-start/swiftui/how-to-disable-the-overlay-color-for-images-inside-button-and-navigationlink)
```swift
// Correct
@ -230,6 +236,13 @@ Button(action: {
AnimatedImage(url: url)
}
.buttonStyle(PlainButtonStyle())
// Or
NavigationView {
NavigationLink(destination: Text("Detail view here")) {
WebImage(url: url)
.renderingMode(.original)
}
}
```
## Demo