Skip to content

Commit c9c35d0

Browse files
committed
Add the convenient method for WebImage to directly supply SwiftUI.Image for placeholder
1 parent 5029a88 commit c9c35d0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

SDWebImageSwiftUI/Classes/WebImage.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,17 @@ extension WebImage {
151151
return result
152152
}
153153

154+
/// Associate a placeholder image when loading image with url
155+
/// - note: This placeholder image will apply the same size and resizable from WebImage for convenience. If you don't want this, use the ViewBuilder one above instead
156+
/// - Parameter image: A Image view that describes the placeholder.
157+
public func placeholder(_ image: Image) -> WebImage {
158+
return placeholder {
159+
configurations.reduce(image) { (previous, configuration) in
160+
configuration(previous)
161+
}
162+
}
163+
}
164+
154165
/// Control the behavior to retry the failed loading when view become appears again
155166
/// - Parameter flag: Whether or not to retry the failed loading
156167
public func retryOnAppear(_ flag: Bool) -> WebImage {

0 commit comments

Comments
 (0)