From 61888409fb79f6a942f7dc412d2964641da05e13 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Sun, 27 Oct 2019 13:12:27 +0800 Subject: [PATCH] Fix macOS indicator center layout issue. Should use the frame origin instead of frame, which will cause issue if superView contains no zero bounds origin --- SDWebImage/Core/UIView+WebCache.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/SDWebImage/Core/UIView+WebCache.m b/SDWebImage/Core/UIView+WebCache.m index 3019b0e0..311dd1ba 100644 --- a/SDWebImage/Core/UIView+WebCache.m +++ b/SDWebImage/Core/UIView+WebCache.m @@ -324,9 +324,7 @@ const int64_t SDWebImageProgressUnitCountUnknown = 1LL; } // Center the indicator view #if SD_MAC - CGPoint center = CGPointMake(NSMidX(self.bounds), NSMidY(self.bounds)); - NSRect frame = view.frame; - view.frame = NSMakeRect(center.x - NSMidX(frame), center.y - NSMidY(frame), NSWidth(frame), NSHeight(frame)); + [view setFrameOrigin:CGPointMake(round((NSWidth(self.bounds) - NSWidth(view.frame)) / 2), round((NSHeight(self.bounds) - NSHeight(view.frame)) / 2))]; #else view.center = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds)); #endif