Skip to content

Commit 0569474

Browse files
committed
Change watchOS private content mode API with property syntax, better for Swift
1 parent 2c9b0b8 commit 0569474

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

SDWebImageSwiftUI/Classes/AnimatedImage.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,8 @@ public struct AnimatedImage : PlatformViewRepresentable {
330330

331331
#if os(macOS)
332332
view.wrapped.imageScaling = contentMode
333-
#elseif os(iOS) || os(tvOS)
333+
#else
334334
view.wrapped.contentMode = contentMode
335-
#elseif os(watchOS)
336-
view.wrapped.setContentMode(contentMode)
337335
#endif
338336

339337
// Animated Image does not support resizing mode and rendering mode

SDWebImageSwiftUI/Classes/ObjC/SDAnimatedImageInterface.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
1515
@interface SDAnimatedImageInterface : WKInterfaceImage
1616

1717
@property (nonatomic, assign, getter=isAnimating, readonly) BOOL animating;
18+
@property (nonatomic, assign) SDImageScaleMode contentMode;
1819
@property (nonatomic, strong, nullable) NSNumber *animationRepeatCount;
1920
@property (nonatomic, copy) NSRunLoopMode runLoopMode;
2021
@property (nonatomic, assign) BOOL resetFrameIndexWhenStopped;
@@ -23,10 +24,6 @@ NS_ASSUME_NONNULL_BEGIN
2324

2425
- (instancetype)init WK_AVAILABLE_WATCHOS_ONLY(6.0);
2526

26-
/// Set the content mode for image
27-
/// @param contentMode The contrent mode
28-
- (void)setContentMode:(SDImageScaleMode)contentMode;
29-
3027
/// Trigger the animation check when view appears/disappears
3128
- (void)updateAnimation;
3229

SDWebImageSwiftUI/Classes/ObjC/SDAnimatedImageInterface.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ - (void)displayLayer:(id<CALayerProtocol>)layer {
174174

175175
// on watchOS, it's the native imageView itself's layer
176176
- (id<CALayerProtocol>)imageViewLayer {
177-
return [[self _interfaceView] layer];
177+
return [self _interfaceView].layer;
178178
}
179179

180180
- (void)updateShouldAnimate
@@ -216,6 +216,10 @@ - (void)setContentMode:(SDImageScaleMode)contentMode {
216216
[self _interfaceView].contentMode = contentMode;
217217
}
218218

219+
- (SDImageScaleMode)contentMode {
220+
return [self _interfaceView].contentMode;
221+
}
222+
219223
@end
220224

221225
#pragma mark - Web Cache

0 commit comments

Comments
 (0)