Update the demo for placeholder comments

This commit is contained in:
DreamPiggy 2019-11-02 14:12:20 +08:00
parent fc9c2b5293
commit 9dcc697a16
2 changed files with 13 additions and 1 deletions

View File

@ -86,6 +86,9 @@ struct ContentView: View {
#if os(macOS) || os(iOS) || os(tvOS) #if os(macOS) || os(iOS) || os(tvOS)
AnimatedImage(url: URL(string:url)) AnimatedImage(url: URL(string:url))
.indicator(SDWebImageActivityIndicator.medium) .indicator(SDWebImageActivityIndicator.medium)
/**
.placeholder(UIImage(systemName: "photo"))
*/
.transition(.fade) .transition(.fade)
.resizable() .resizable()
.scaledToFit() .scaledToFit()
@ -100,6 +103,11 @@ struct ContentView: View {
#if os(macOS) || os(iOS) || os(tvOS) #if os(macOS) || os(iOS) || os(tvOS)
WebImage(url: URL(string:url)) WebImage(url: URL(string:url))
.resizable() .resizable()
/**
.placeholder {
Image(systemName: "photo")
}
*/
.indicator(.activity) .indicator(.activity)
.animation(.easeInOut(duration: 0.5)) .animation(.easeInOut(duration: 0.5))
.transition(.fade) .transition(.fade)

View File

@ -90,8 +90,11 @@ var body: some View {
// Success // Success
} }
.resizable() // Resizable like SwiftUI.Image .resizable() // Resizable like SwiftUI.Image
.placeholder {
Image(systemName: "photo") // Placeholder
}
.indicator(.activity) // Activity Indicator .indicator(.activity) // Activity Indicator
.animation(.easeInOut(duration: 0.5)) .animation(.easeInOut(duration: 0.5)) // Animation Duration
.transition(.fade) // Fade Transition .transition(.fade) // Fade Transition
.scaledToFit() .scaledToFit()
.frame(width: 300, height: 300, alignment: .center) .frame(width: 300, height: 300, alignment: .center)
@ -118,6 +121,7 @@ var body: some View {
// Error // Error
} }
.resizable() // Actually this is not needed unlike SwiftUI.Image .resizable() // Actually this is not needed unlike SwiftUI.Image
.placeholder(UIImage(systemName: "photo")) // Placeholder
.indicator(SDWebImageActivityIndicator.medium) // Activity Indicator .indicator(SDWebImageActivityIndicator.medium) // Activity Indicator
.transition(.fade) // Fade Transition .transition(.fade) // Fade Transition
.scaledToFit() // Attention to call it on AnimatedImage, but not `some View` after View Modifier .scaledToFit() // Attention to call it on AnimatedImage, but not `some View` after View Modifier