Skip to content

Commit 5d949dc

Browse files
committed
Add needs layout after the layout model changed
1 parent 611ab61 commit 5d949dc

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

SDWebImageSwiftUI/Classes/AnimatedImage.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ public struct AnimatedImage : ViewRepresentable {
7373

7474
func layoutView(_ view: AnimatedImageViewWrapper, context: ViewRepresentableContext<AnimatedImage>) {
7575
// AspectRatio
76-
if let aspectRatio = imageLayout.aspectRatio {
77-
// Not implements
76+
if let _ = imageLayout.aspectRatio {
77+
// TODO: Needs layer transform and geometry calculation
7878
}
79+
7980
// ContentMode
8081
switch imageLayout.contentMode {
8182
case .fit:
@@ -91,6 +92,7 @@ public struct AnimatedImage : ViewRepresentable {
9192
view.wrapped.contentMode = .scaleToFill
9293
#endif
9394
}
95+
9496
// RenderingMode
9597
if let renderingMode = imageLayout.renderingMode {
9698
switch renderingMode {
@@ -111,6 +113,7 @@ public struct AnimatedImage : ViewRepresentable {
111113
break
112114
}
113115
}
116+
114117
// Interpolation
115118
if let interpolation = imageLayout.interpolation {
116119
switch interpolation {
@@ -129,15 +132,16 @@ public struct AnimatedImage : ViewRepresentable {
129132
} else {
130133
view.interpolationQuality = .default
131134
}
135+
132136
// Antialiased
133137
view.shouldAntialias = imageLayout.antialiased
134138

135139
// Display
136140
#if os(macOS)
137-
view.updateConstraintsIfNeeded()
141+
view.needsLayout = true
138142
view.needsDisplay = true
139143
#else
140-
view.updateConstraintsIfNeeded()
144+
view.setNeedsLayout()
141145
view.setNeedsDisplay()
142146
#endif
143147
}

0 commit comments

Comments
 (0)