File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed
SDWebImageSwiftUI/Classes Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -383,6 +383,13 @@ public struct AnimatedImage : PlatformViewRepresentable {
383
383
// disable custom loop count
384
384
view. wrapped. shouldCustomLoopCount = false
385
385
}
386
+ #elseif os(watchOS)
387
+ if let customLoopCount = imageConfiguration. customLoopCount {
388
+ view. wrapped. setAnimationRepeatCount ( customLoopCount as NSNumber )
389
+ } else {
390
+ // disable custom loop count
391
+ view. wrapped. setAnimationRepeatCount ( nil )
392
+ }
386
393
#endif
387
394
}
388
395
}
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
14
14
15
15
- (instancetype )init WK_AVAILABLE_WATCHOS_ONLY(6.0 );
16
16
- (void )setContentMode : (SDImageScaleMode)contentMode ;
17
+ - (void )setAnimationRepeatCount : (nullable NSNumber *)repeatCount ;
17
18
18
19
@end
19
20
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ @interface SDAnimatedImageInterface () {
59
59
@property (nonatomic , strong ) UIImage<SDAnimatedImage> *animatedImage;
60
60
@property (nonatomic , assign ) CGFloat animatedImageScale;
61
61
@property (nonatomic , strong ) SDAnimatedImageStatus *currentStatus;
62
+ @property (nonatomic , strong ) NSNumber *animationRepeatCount;
62
63
63
64
@end
64
65
@@ -136,7 +137,12 @@ - (void)setImage:(UIImage *)image {
136
137
137
138
- (void )startBuiltInAnimationWithImage : (UIImage<SDAnimatedImage> *)animatedImage {
138
139
NSData *animatedImageData = animatedImage.animatedImageData ;
139
- NSUInteger maxLoopCount = 0 ;
140
+ NSUInteger maxLoopCount;
141
+ if (self.animationRepeatCount != nil ) {
142
+ maxLoopCount = self.animationRepeatCount .unsignedIntegerValue ;
143
+ } else {
144
+ maxLoopCount = animatedImage.animatedImageLoopCount ;
145
+ }
140
146
if (maxLoopCount == 0 ) {
141
147
// The documentation says `kCFNumberPositiveInfinity may be used`, but it actually treat as 1 loop count
142
148
// 0 was treated as 1 loop count as well, not the same as Image/IO or UIKit
You can’t perform that action at this time.
0 commit comments