Add a FAQ-Common Problems for some common questions which don't need to explain over time and time

This commit is contained in:
DreamPiggy 2019-11-16 17:51:15 +08:00
parent 7f6f23f7d4
commit a6f495a29c
1 changed files with 29 additions and 0 deletions

View File

@ -198,6 +198,35 @@ func application(_ application: UIApplication, didFinishLaunchingWithOptions lau
For more information, it's really recommended to check our demo, to learn detailed API usage. You can also have a check at the latest API documentation, for advanced usage.
## FAQ
### Common Problems
+ Using Image/WebImage/AnimatedImage in Button/NavigationLink
SwiftUI's button apply overlay to its content (except Text) by default, this is common mistake to write code like this, which cause strange behavior:
```swift
// Wrong
Button(action: {
// Clicked
}) {
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)
```swift
// Correct
Button(action: {
// Clicked
}) {
AnimatedImage(url: url)
}
.buttonStyle(PlainButtonStyle())
```
## Documentation
+ [SDWebImageSwiftUI API documentation](https://sdwebimage.github.io/SDWebImageSwiftUI/)