@@ -88,11 +88,11 @@ - (UIColor *)colorForKey:(NSString *)key forTheme:(NSString *)themeName
8888 NSString *colorValue = [self objectForKey: key forTheme: themeName];
8989 UIColor *color = [self colorFromString: colorValue];
9090 if (color == nil && [self isValidString: colorValue]) {
91- NSArray * referenceColor = [colorValue componentsSeparatedByString: @" :" ];
91+ NSArray * referenceColor = [colorValue componentsSeparatedByString: @" :" ];
9292 colorValue = referenceColor.firstObject ;
9393 color = [self colorForKey: colorValue forTheme: themeName];
9494 if (referenceColor.count > 1 ) {
95- color = [color colorWithAlphaComponent: [referenceColor[1 ] doubleValue ]];
95+ color = [color colorWithAlphaComponent: [referenceColor[1 ] doubleValue ]];
9696 }
9797 }
9898
@@ -118,21 +118,48 @@ - (UIColor*)colorFromString:(NSString*)colorValue
118118 return nil ;
119119}
120120
121- - (UIImage *)imageNamed : (NSString *)imgName
121+ - (UIImage *)imageNamed : (NSString *)key
122122{
123- return [self imageNamed: imgName forTheme: self .currentTheme];;
123+ return [self imageNamed: key forTheme: self .currentTheme];;
124124}
125125
126- - (UIImage *)imageNamed : (NSString *)imgName forTheme : (NSString *)themeName
126+ - (UIImage *)imageNamed : (NSString *)key forTheme : (NSString *)themeName
127127{
128- if ([self isValidString: themeName] == NO || [self isValidString: imgName ] == NO ) {
128+ if ([self isValidString: themeName] == NO || [self isValidString: key ] == NO ) {
129129 return nil ;
130130 }
131131
132- NSString *path = self.themeList [themeName];
133- path = [self relativePathToMainBundle: path];
134- NSString *filePath = [path stringByAppendingPathComponent: imgName];
135- UIImage *img = [UIImage imageNamed: filePath];
132+ NSString *imgName = [self objectForKey: key forTheme: themeName];
133+
134+ if (imgName == nil ) {
135+ imgName = key;
136+ }
137+
138+ UIImage* img = nil ;
139+ NSBundle * bundle = [NSBundle bundleWithPath: self .themeList[themeName]];
140+
141+ if (NSFoundationVersionNumber >= NSFoundationVersionNumber_iOS_8_0) {
142+ img = [UIImage imageNamed: key inBundle: bundle compatibleWithTraitCollection: nil ];
143+ }
144+ else {
145+ #ifdef AWLThemeManager_XCASSETS_iOS7
146+ // This is included for reference/completeness. It fetches the device specific
147+ // image from the compiled Assets.car embedded in the theme bundle for iOS7 devices.
148+ // However, it is a *PRIVATE API*
149+ // As such, all relevant warnings and caveats apply to it's usage
150+ // IF you want to enable with cocoapods you'll need this:
151+ // https://guides.cocoapods.org/syntax/podfile.html#post_install
152+ static NSString * iOS7PrivateCompatSelector = @" _" @" device" @" Specific" @" ImageNamed:" @" inBundle:" ;
153+ img = [UIImage performSelector: NSSelectorFromString (iOS7PrivateCompatSelector) withObject: imgName withObject: bundle];
154+ #endif
155+ }
156+
157+ if (img == nil ) {
158+ NSString *path = self.themeList [themeName];
159+ path = [self relativePathToMainBundle: path];
160+ NSString *filePath = [path stringByAppendingPathComponent: imgName];
161+ img = [UIImage imageNamed: filePath];
162+ }
136163
137164 if (img == nil ) {
138165 NSString *baseTheme = self.themeRelationship [themeName];
0 commit comments