Skip to content

Commit 9d7dd52

Browse files
committed
add 3.0.0 version
1 parent b47a71c commit 9d7dd52

File tree

2 files changed

+32
-29
lines changed

2 files changed

+32
-29
lines changed

Source/SkinManager/YASkinManager.m

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#define YA_SKIN_MANAGER_UD_KEY @"YA_SKIN_NAME"
1313
#define YA_SKIN_CATEGORY(__KEY) ((__KEY != nil) ? __KEY : @"default")
1414

15-
@interface YASkinManager()
15+
@interface YASkinManager ()
1616

1717
@property (nonatomic, strong) NSDictionary *skinDictionary;
1818
@property (nonatomic, strong) NSBundle *skinBundle;
@@ -29,10 +29,10 @@ + (instancetype)sharedManager
2929
{
3030
static dispatch_once_t onceToken;
3131
dispatch_once(&onceToken, ^{
32-
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
33-
NSString *skinName = [userDefaults objectForKey:YA_SKIN_MANAGER_UD_KEY];
34-
35-
gSharedInstance = [[YASkinManager alloc] initWithSkinName:skinName];
32+
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
33+
NSString *skinName = [userDefaults objectForKey:YA_SKIN_MANAGER_UD_KEY];
34+
35+
gSharedInstance = [[YASkinManager alloc] initWithSkinName:skinName];
3636
});
3737
return gSharedInstance;
3838
}
@@ -63,10 +63,10 @@ - (void)setSkinName:(NSString *)skinName
6363
_skinName = (skinName != nil) ? skinName : @"DefaultSkin";
6464
_skinBundle = [NSBundle bundleWithURL:[[NSBundle mainBundle] URLForResource:_skinName withExtension:@"bundle"]];
6565
NSAssert(_skinBundle != nil, @"Skin Bundle should not be nil!");
66-
66+
6767
NSURL *skinFileURL = [_skinBundle URLForResource:@"config" withExtension:@".plist"];
6868
self.skinDictionary = [NSDictionary dictionaryWithContentsOfURL:skinFileURL];
69-
69+
7070
if (self == gSharedInstance) {
7171
[[NSUserDefaults standardUserDefaults] setObject:_skinName forKey:YA_SKIN_MANAGER_UD_KEY];
7272
[[NSUserDefaults standardUserDefaults] synchronize];
@@ -83,13 +83,12 @@ - (UIColor *)colorForTag:(NSString *)tag
8383
if (!colorHex) {
8484
colorHex = [colorDict objectForKey:YA_SKIN_CATEGORY(nil)];
8585
}
86-
86+
8787
UIColor *color = nil;
8888
if ([colorHex isKindOfClass:[NSNumber class]]) {
8989
color = [UIColor colorWithHex:[colorHex integerValue]];
90-
} else if ([colorHex isKindOfClass:[NSString class]]) {
91-
color = [UIColor colorWithHexString:colorHex];
9290
}
91+
9392
return color;
9493
}
9594

@@ -100,13 +99,13 @@ - (UIFont *)fontForTag:(NSString *)tag
10099
if (fontFamily == nil) {
101100
fontFamily = [fontFamilyDict objectForKey:YA_SKIN_CATEGORY(nil)];
102101
}
103-
102+
104103
NSDictionary *fontSizeDict = self.skinDictionary[@"Font-Size"];
105-
NSNumber *fontSize = [fontSizeDict objectForKey:YA_SKIN_CATEGORY(tag)];
104+
NSNumber *fontSize = [fontSizeDict objectForKey:YA_SKIN_CATEGORY(tag)];
106105
if (fontSize == nil) {
107106
fontSize = [fontSizeDict objectForKey:YA_SKIN_CATEGORY(nil)];
108107
}
109-
108+
110109
return [UIFont fontWithName:fontFamily size:fontSize.floatValue];
111110
}
112111

@@ -121,9 +120,10 @@ - (UIImage *)imageWithName:(NSString *)imageName cache:(BOOL)flag
121120
if (cachedImage == nil) {
122121
NSString *filename = [imageName stringByDeletingPathExtension];
123122
NSString *extension = [imageName pathExtension];
124-
if ([extension length] == 0) extension = @"png";
123+
if ([extension length] == 0)
124+
extension = @"png";
125125
NSBundle *bundle = self.skinBundle;
126-
126+
127127
NSString *imagePath = nil;
128128
if ([UIScreen mainScreen].scale == 3.0) {
129129
imagePath = [self ya_plusImagePathWithName:filename extension:extension inBundle:bundle];
@@ -133,21 +133,24 @@ - (UIImage *)imageWithName:(NSString *)imageName cache:(BOOL)flag
133133
NSString *imageForiPhone5 = [NSString stringWithFormat:@"%@-568h@2x", filename];
134134
imagePath = [bundle pathForResource:imageForiPhone5 ofType:extension];
135135
}
136-
136+
137137
// If no image specified for iPhone 5, fallback to normal retina image.
138-
if (imagePath == nil) imagePath = [self __retainImagePathWithName:filename extension:extension inBundle:bundle];
139-
138+
if (imagePath == nil)
139+
imagePath = [self __retainImagePathWithName:filename extension:extension inBundle:bundle];
140+
140141
// If no image specified for Retain, fallback to normal image.
141-
if (imagePath == nil) imagePath = [bundle pathForResource:filename ofType:extension];
142+
if (imagePath == nil)
143+
imagePath = [bundle pathForResource:filename ofType:extension];
142144
} else {
143145
imagePath = [bundle pathForResource:filename ofType:extension];
144-
146+
145147
// If no image For Normal, fallback to Normal Retain Image.
146-
if (imagePath == nil) imagePath = [self __retainImagePathWithName:filename extension:extension inBundle:bundle];
148+
if (imagePath == nil)
149+
imagePath = [self __retainImagePathWithName:filename extension:extension inBundle:bundle];
147150
}
148-
151+
149152
UIImage *image = (imagePath != nil) ? [UIImage imageWithContentsOfFile:imagePath] : nil;
150-
153+
151154
if (image == nil) {
152155
NSLog(@"[PASkinManager] Failed to get image with name: %@", imageName);
153156
} else {
@@ -169,12 +172,11 @@ - (void)cleanImageCache
169172

170173
#pragma mark - Private
171174

172-
- (NSString *)ya_plusImagePathWithName:(NSString *)imageName
173-
extension:(NSString *)extension
174-
inBundle:(NSBundle *)bundle
175+
- (NSString *)ya_plusImagePathWithName:(NSString *)imageName extension:(NSString *)extension inBundle:(NSBundle *)bundle
175176
{
176177
NSString *retinaName = [NSString stringWithFormat:@"%@@3x", imageName];
177-
if (bundle == nil) bundle = [NSBundle mainBundle];
178+
if (bundle == nil)
179+
bundle = [NSBundle mainBundle];
178180
return [bundle pathForResource:retinaName ofType:extension];
179181
}
180182

@@ -183,7 +185,8 @@ - (NSString *)__retainImagePathWithName:(NSString *)imageName
183185
inBundle:(NSBundle *)bundle
184186
{
185187
NSString *retinaName = [NSString stringWithFormat:@"%@@2x", imageName];
186-
if (bundle == nil) bundle = [NSBundle mainBundle];
188+
if (bundle == nil)
189+
bundle = [NSBundle mainBundle];
187190
return [bundle pathForResource:retinaName ofType:extension];
188191
}
189192

YAUIKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = 'YAUIKit'
4-
s.version = '2.5.10'
4+
s.version = '3.0.0'
55
s.summary = 'YAUIKit'
66
s.homepage = 'https://github.com/candyan/YAUIKit'
77
s.license = 'MIT'

0 commit comments

Comments
 (0)