Skip to content

Commit 3982797

Browse files
committed
Fix the watchOS compile issue
1 parent 1b23e14 commit 3982797

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

SDWebImageSwiftUI/Classes/WebImage.swift

+7-6
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,12 @@ public struct WebImage : View {
138138
// ensure CGImage is nil
139139
if image.cgImage == nil {
140140
// draw vector into bitmap with the screen scale (behavior like AppKit)
141-
UIGraphicsBeginImageContextWithOptions(image.size, false, UIScreen.main.scale)
141+
#if os(iOS) || os(tvOS)
142+
let scale = UIScreen.main.scale
143+
#else
144+
let scale = WKInterfaceDevice.current().screenScale
145+
#endif
146+
UIGraphicsBeginImageContextWithOptions(image.size, false, scale)
142147
image.draw(at: .zero)
143148
cgImage = UIGraphicsGetImageFromCurrentImageContext()?.cgImage
144149
UIGraphicsEndImageContext()
@@ -154,11 +159,7 @@ public struct WebImage : View {
154159
if let cgImage = cgImage {
155160
let scale = image.scale
156161
let orientation = image.imageOrientation.toSwiftUI
157-
if let label = image.accessibilityLabel {
158-
result = Image(cgImage, scale: scale, orientation: orientation, label: Text(label))
159-
} else {
160-
result = Image(decorative: cgImage, scale: scale, orientation: orientation)
161-
}
162+
result = Image(decorative: cgImage, scale: scale, orientation: orientation)
162163
} else {
163164
result = Image(uiImage: image)
164165
}

0 commit comments

Comments
 (0)