Add support for new system built-in indicator with medium and large style. Fallback on OS version which does not support dark mode

This commit is contained in:
DreamPiggy 2019-06-10 20:13:25 +08:00
parent 547f9d895e
commit 0379273b48
2 changed files with 34 additions and 0 deletions

View File

@ -74,6 +74,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
@property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *largeIndicator;
/// medium activity indicator, supports dark mode if available
@property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *mediumIndicator;
@end

View File

@ -124,6 +124,36 @@
return indicator;
}
+ (SDWebImageActivityIndicator *)largeIndicator {
SDWebImageActivityIndicator *indicator = [SDWebImageActivityIndicator new];
#if SD_UIKIT
if (@available(iOS 13.0, tvOS 13.0, *)) {
indicator.indicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleLarge;
} else {
indicator.indicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
}
#else
indicator.indicatorView.controlSize = NSControlSizeRegular;
[indicator.indicatorView sizeToFit];
#endif
return indicator;
}
+ (SDWebImageActivityIndicator *)mediumIndicator {
SDWebImageActivityIndicator *indicator = [SDWebImageActivityIndicator new];
#if SD_UIKIT
if (@available(iOS 13.0, tvOS 13.0, *)) {
indicator.indicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleMedium;
} else {
indicator.indicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite;
}
#else
indicator.indicatorView.controlSize = NSControlSizeSmall;
[indicator.indicatorView sizeToFit];
#endif
return indicator;
}
@end
#pragma mark - Progress Indicator