Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Use imageWithConfiguration: on iOS 13+
Browse files Browse the repository at this point in the history
  • Loading branch information
levinli303 committed Jul 20, 2020
1 parent 9a0cce8 commit 67ce9fb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 8 additions & 2 deletions Sources/DarkModeCore/DMDynamicImage.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ - (instancetype)initWithLightImage:(UIImage *)lightImage darkImage:(UIImage *)da
- (UIImage *)resolvedImage {
if (DMTraitCollection.overrideTraitCollection.userInterfaceStyle == DMUserInterfaceStyleDark) {
return self.darkImage;
} else {
return self.lightImage;
}
return self.lightImage;
}

- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel {
Expand Down Expand Up @@ -88,6 +87,13 @@ - (UIImage *)imageWithHorizontallyFlippedOrientation {
darkImage:[self.darkImage imageWithHorizontallyFlippedOrientation]];
}

- (UIImage *)imageWithConfiguration:(UIImageConfiguration *)configuration API_AVAILABLE(ios(13.0)) {
if (configuration.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
return [_darkImage imageWithConfiguration:configuration];
}
return [_lightImage imageWithConfiguration:configuration];
}

- (id)copy {
return [self copyWithZone:nil];
}
Expand Down
4 changes: 3 additions & 1 deletion Sources/DarkModeCore/UIImage+DarkModeKitSwizzling.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

@import ObjectiveC;

static BOOL _useUIImageAsset = NO;
static BOOL _useUIImageAsset = YES;

@implementation UIImage (DarkModeKitSwizzling)

Expand Down Expand Up @@ -38,6 +38,8 @@ + (void)dm_swizzleIsEqual {
}
return ((BOOL(*)(UIImage *, SEL, UIImage *))imp)(realSelf, selector, realOther);
}), method_getTypeEncoding(method));

_useUIImageAsset = NO;
});
}

Expand Down

0 comments on commit 67ce9fb

Please sign in to comment.