Fix that macOS indicator always use dynamic mode. Now only the `largeIndicator` and `mediumIndicator` supports dynamic dark mode switch

This commit is contained in:
DreamPiggy 2019-06-10 21:20:25 +08:00
parent e81de4fa39
commit d67aebeeed
3 changed files with 10 additions and 2 deletions

View File

@ -35,6 +35,7 @@
self.imageView1.sd_imageIndicator = SDWebImageProgressIndicator.defaultIndicator;
[self.imageView1 sd_setImageWithURL:[NSURL URLWithString:@"https://raw.githubusercontent.com/recurser/exif-orientation-examples/master/Landscape_2.jpg"] placeholderImage:nil options:SDWebImageProgressiveLoad];
// NSImageView + Animated Image
self.imageView2.sd_imageIndicator = SDWebImageActivityIndicator.largeIndicator;
[self.imageView2 sd_setImageWithURL:[NSURL URLWithString:@"https:raw.githubusercontent.com/onevcat/APNGKit/master/TestImages/APNG-cube.apng"]];
// SDAnimatedImageView + Static Image
[self.imageView3 sd_setImageWithURL:[NSURL URLWithString:@"https://nr-platform.s3.amazonaws.com/uploads/platform/published_extension/branding_icon/275/AmazonS3.png"]];

View File

@ -66,6 +66,7 @@
*/
@interface SDWebImageActivityIndicator (Conveniences)
/// These indicator use the fixed color without dark mode support
/// gray-style activity indicator
@property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *grayIndicator;
/// large gray-style activity indicator
@ -74,9 +75,10 @@
@property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *whiteIndicator;
/// large white-style activity indicator
@property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *whiteLargeIndicator;
/// large activity indicator, supports dark mode if available
/// These indicator use the system style, supports dark mode if available (iOS 13+/macOS 10.14+)
/// large activity indicator
@property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *largeIndicator;
/// medium activity indicator, supports dark mode if available
/// medium activity indicator
@property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *mediumIndicator;
@end

View File

@ -93,6 +93,8 @@ static NSInteger UIActivityIndicatorViewStyleLarge = 101;
#else
indicator.indicatorView.color = [UIColor colorWithWhite:0 alpha:0.45]; // Color from `UIActivityIndicatorViewStyleGray`
#endif
#else
indicator.indicatorView.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua]; // Disable dark mode support
#endif
return indicator;
}
@ -104,6 +106,7 @@ static NSInteger UIActivityIndicatorViewStyleLarge = 101;
indicator.indicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
indicator.indicatorView.color = grayColor;
#else
indicator.indicatorView.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua]; // Disable dark mode support
indicator.indicatorView.controlSize = NSControlSizeRegular;
#endif
[indicator.indicatorView sizeToFit];
@ -115,6 +118,7 @@ static NSInteger UIActivityIndicatorViewStyleLarge = 101;
#if SD_UIKIT
indicator.indicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite;
#else
indicator.indicatorView.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua]; // Disable dark mode support
CIFilter *lighten = [CIFilter filterWithName:@"CIColorControls"];
[lighten setDefaults];
[lighten setValue:@(1) forKey:kCIInputBrightnessKey];
@ -128,6 +132,7 @@ static NSInteger UIActivityIndicatorViewStyleLarge = 101;
#if SD_UIKIT
indicator.indicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
#else
indicator.indicatorView.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua]; // Disable dark mode support
indicator.indicatorView.controlSize = NSControlSizeRegular;
[indicator.indicatorView sizeToFit];
#endif