Skip to content

Commit 25304b6

Browse files
committed
Fix the progerss indicator width on macOS. After we use the new solution for indicator
1 parent 697dc8b commit 25304b6

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

SDWebImageSwiftUI/Classes/ImageViewWrapper.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class ProgressIndicatorWrapper : PlatformView {
6565
#if os(macOS)
6666
public override func layout() {
6767
super.layout()
68-
wrapped.setFrameOrigin(CGPoint(x: (self.bounds.width - wrapped.frame.width) / 2, y: (self.bounds.height - wrapped.frame.height) / 2))
68+
wrapped.setFrameOrigin(CGPoint(x: round(self.bounds.width - wrapped.frame.width) / 2, y: round(self.bounds.height - wrapped.frame.height) / 2))
6969
}
7070
#else
7171
public override func layoutSubviews() {

SDWebImageSwiftUI/Classes/Indicator/ProgressIndicator.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ public struct ProgressIndicator: PlatformViewRepresentable {
6767
view.style = .bar
6868
view.isDisplayedWhenStopped = false
6969
view.controlSize = .small
70+
view.frame = CGRect(x: 0, y: 0, width: 160, height: 0) // Width from `UIProgressView` default width
71+
view.sizeToFit()
72+
view.autoresizingMask = [.maxXMargin, .minXMargin, .maxYMargin, .minYMargin]
7073
return nsView
7174
}
7275

0 commit comments

Comments
 (0)