Skip to content

Commit 12aae41

Browse files
committed
Merge branch 'SDWebImage-master'
2 parents c4ac0ef + f30eb85 commit 12aae41

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

SDWebImageSwiftUI/Classes/ImageViewWrapper.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import SwiftUI
5555
public override var intrinsicContentSize: CGSize {
5656
/// Match the behavior of SwiftUI.Image, only when image is resizable, use the super implementation to calculate size
5757
let contentSize = wrapped.intrinsicContentSize
58-
if let _ = resizingMode {
58+
if resizingMode != nil {
5959
/// Keep aspect ratio
6060
if contentSize.width > 0 && contentSize.height > 0 {
6161
let ratio = contentSize.width / contentSize.height
@@ -74,15 +74,21 @@ import SwiftUI
7474
super.init(frame: frameRect)
7575
addSubview(wrapped)
7676
observation = observe(\.wrapped.image, options: [.new]) { [weak self] _, _ in
77-
self?.invalidateIntrinsicContentSize()
77+
guard let self = self else {
78+
return
79+
}
80+
self.invalidateIntrinsicContentSize()
7881
}
7982
}
8083

8184
public required init?(coder: NSCoder) {
8285
super.init(coder: coder)
8386
addSubview(wrapped)
8487
observation = observe(\.wrapped.image, options: [.new]) { [weak self] _, _ in
85-
self?.invalidateIntrinsicContentSize()
88+
guard let self = self else {
89+
return
90+
}
91+
self.invalidateIntrinsicContentSize()
8692
}
8793
}
8894
}

0 commit comments

Comments
 (0)