Skip to content

Commit 123ea5d

Browse files
committed
fix img load error for iOS 7
1 parent 37eaa56 commit 123ea5d

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

AWLThemeManager/AWLThemeManager.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ - (UIImage *)imageNamed:(NSString *)imgName forTheme:(NSString*)themeName
121121
}
122122

123123
NSString *path = self.themeList[themeName];
124+
path = [self relativePathToMainBundle:path];
124125
NSString *filePath = [path stringByAppendingPathComponent:imgName];
125126
UIImage *img = [UIImage imageNamed:filePath];
127+
126128
if (img == nil) {
127129
NSString *baseTheme = self.themeRelationship[themeName];
128130
img = [self imageNamed:imgName forTheme:baseTheme];
@@ -131,6 +133,14 @@ - (UIImage *)imageNamed:(NSString *)imgName forTheme:(NSString*)themeName
131133
return img;
132134
}
133135

136+
- (NSString*)relativePathToMainBundle:(NSString*)path
137+
{
138+
NSString *mainBundlePath = [[NSBundle mainBundle] bundlePath];
139+
NSString *appDirectory = [mainBundlePath stringByDeletingLastPathComponent];
140+
NSString *relativePath = [path stringByReplacingOccurrencesOfString:appDirectory withString:@".."];
141+
return relativePath;
142+
}
143+
134144
- (UIFont *)fontForKey:(NSString *)key
135145
{
136146
return [self fontForKey:key forTheme:self.currentTheme];

ThemeManagerDemo/ThemeManagerDemo.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@
367367
buildSettings = {
368368
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
369369
INFOPLIST_FILE = ThemeManagerDemo/Info.plist;
370+
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
370371
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
371372
PRODUCT_NAME = "$(TARGET_NAME)";
372373
};
@@ -377,6 +378,7 @@
377378
buildSettings = {
378379
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
379380
INFOPLIST_FILE = ThemeManagerDemo/Info.plist;
381+
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
380382
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
381383
PRODUCT_NAME = "$(TARGET_NAME)";
382384
};

0 commit comments

Comments
 (0)