From 011131c0777de0912d9647241e60f4c47bf1976a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=93=8D?= Date: Mon, 13 Jun 2016 16:36:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96JSON=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=86=85=E9=83=A8=E6=9C=BA=E5=88=B6=20,=20JSON=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E8=87=AA=E5=AE=9A=E4=B9=89Block=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LEETheme.podspec | 4 +- LEEThemeDemo/LEEThemeDemo/LEETheme/LEETheme.h | 53 ++-- LEEThemeDemo/LEEThemeDemo/LEETheme/LEETheme.m | 249 +++++++++--------- LEEThemeDemo/LEEThemeDemo/ViewController.m | 6 + LEEThemeDemo/LEEThemeDemo/tag_blue_json.json | 2 +- LEEThemeDemo/LEEThemeDemo/tag_gray_json.json | 4 + LEEThemeDemo/LEEThemeDemo/tag_green_json.json | 2 +- LEEThemeDemo/LEEThemeDemo/tag_red_json.json | 2 +- 8 files changed, 184 insertions(+), 138 deletions(-) diff --git a/LEETheme.podspec b/LEETheme.podspec index 6bad691..8da0af3 100644 --- a/LEETheme.podspec +++ b/LEETheme.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "LEETheme" -s.version = "1.0.3" +s.version = "1.0.4" s.summary = "最好用的主题管理库" s.homepage = "https://github.com/lixiang1994/LEETheme" @@ -14,7 +14,7 @@ s.author = { "LEE" => "applelixiang@126.com" } s.platform = :ios s.platform = :ios, "7.0" -s.source = { :git => "https://github.com/lixiang1994/LEETheme.git", :tag => "1.0.3"} +s.source = { :git => "https://github.com/lixiang1994/LEETheme.git", :tag => "1.0.4"} s.source_files = "LEEThemeDemo/LEEThemeDemo/LEETheme/**/*.{h,m}" diff --git a/LEEThemeDemo/LEEThemeDemo/LEETheme/LEETheme.h b/LEEThemeDemo/LEEThemeDemo/LEETheme/LEETheme.h index 491ab8d..0ef3f47 100644 --- a/LEEThemeDemo/LEEThemeDemo/LEETheme/LEETheme.h +++ b/LEEThemeDemo/LEEThemeDemo/LEETheme/LEETheme.h @@ -13,7 +13,7 @@ * * @author LEE * @copyright Copyright © 2016年 lee. All rights reserved. - * @version V1.0.3 + * @version V1.0.4 */ #import @@ -22,6 +22,7 @@ @class LEEThemeConfigModel; typedef void(^LEEThemeConfigBlock)(id item); +typedef void(^LEEThemeConfigBlockToIdentifier)(id item , id value); typedef LEEThemeConfigModel *(^LEEConfigThemeToFloat)(CGFloat number); typedef LEEThemeConfigModel *(^LEEConfigThemeToIdentifier)(NSString *identifier); typedef LEEThemeConfigModel *(^LEEConfigThemeToColor)(NSString *tag , UIColor *color); @@ -35,7 +36,8 @@ typedef LEEThemeConfigModel *(^LEEConfigThemeToImageAndState)(NSString *tag , UI typedef LEEThemeConfigModel *(^LEEConfigThemeToImageAndState)(NSString *tag , UIImage *image , UIControlState state); typedef LEEThemeConfigModel *(^LEEConfigThemeToKeyPathAndColor)(NSString *tag , NSString *keyPath , UIColor *color); typedef LEEThemeConfigModel *(^LEEConfigThemeToKeyPathAndImage)(NSString *tag , NSString *keyPath , id image); -typedef LEEThemeConfigModel *(^LEEConfigThemeToKeyPathAndString)(NSString *tag , NSString *keyPath , NSString *string); +typedef LEEThemeConfigModel *(^LEEConfigThemeToIdentifierAndBlock)(NSString *identifier , LEEThemeConfigBlockToIdentifier); + /* ********************************************************************************* @@ -131,6 +133,10 @@ typedef LEEThemeConfigModel *(^LEEConfigThemeToKeyPathAndString)(NSString *tag , @property (nonatomic , copy , readonly ) LEEConfigThemeToColor LeeAddBackgroundColor; /** 添加占位符颜色设置 -> 格式: .LeeAddPlaceholderColor(@@"tag" , UIColor) */ @property (nonatomic , copy , readonly ) LEEConfigThemeToColor LeeAddPlaceholderColor; +/** 添加进度轨道渲染颜色设置 -> 格式: .LeeAddTrackTintColor(@@"tag" , UIColor) */ +@property (nonatomic , copy , readonly ) LEEConfigThemeToColor LeeAddTrackTintColor; +/** 添加进度渲染颜色设置 -> 格式: .LeeAddProgressTintColor(@@"tag" , UIColor) */ +@property (nonatomic , copy , readonly ) LEEConfigThemeToColor LeeAddProgressTintColor; /** 添加高亮文本颜色设置 -> 格式: .LeeAddHighlightedTextColor(@@"tag" , UIColor) */ @property (nonatomic , copy , readonly ) LEEConfigThemeToColor LeeAddHighlightedTextColor; /** 添加页数指示渲染颜色设置 -> 格式: .LeeAddPageIndicatorTintColor(@@"tag" , UIColor) */ @@ -142,41 +148,45 @@ typedef LEEThemeConfigModel *(^LEEConfigThemeToKeyPathAndString)(NSString *tag , /** 添加按钮标题阴影颜色设置 -> 格式: .LeeAddButtonTitleShadowColor(@@"tag" , UIColor , UIControlStateNormal) */ @property (nonatomic , copy , readonly ) LEEConfigThemeToColorAndState LeeAddButtonTitleShadowColor; -/** 添加属性颜色设置 -> 格式: .LeeAddKeyPathAndColor(@@"tag" , @"keyPath" , UIColor) */ +/** 添加属性颜色设置 -> 格式: .LeeAddKeyPathAndColor(@@"tag" , @@"keyPath" , UIColor) */ @property (nonatomic , copy , readonly ) LEEConfigThemeToKeyPathAndColor LeeAddKeyPathAndColor; /** Image */ -/** 添加图片设置 -> 格式: .LeeAddImage(@@"tag" , UIImage 或 @"imageName" 或 @"imagePath") */ +/** 添加图片设置 -> 格式: .LeeAddImage(@@"tag" , UIImage 或 @@"imageName" 或 @@"imagePath") */ @property (nonatomic , copy , readonly ) LEEConfigThemeToImage LeeAddImage; -/** 添加阴影图片设置 -> 格式: .LeeAddShadowImage(@@"tag" , UIImage 或 @"imageName" 或 @"imagePath") */ +/** 添加进度轨道图片设置 -> 格式: .LeeAddTrackImage(@@"tag" , UIImage 或 @@"imageName" 或 @@"imagePath") */ +@property (nonatomic , copy , readonly ) LEEConfigThemeToImage LeeAddTrackImage; +/** 添加进度图片设置 -> 格式: .LeeAddProgressImage(@@"tag" , UIImage 或 @@"imageName" 或 @@"imagePath") */ +@property (nonatomic , copy , readonly ) LEEConfigThemeToImage LeeAddProgressImage; +/** 添加阴影图片设置 -> 格式: .LeeAddShadowImage(@@"tag" , UIImage 或 @@"imageName" 或 @@"imagePath") */ @property (nonatomic , copy , readonly ) LEEConfigThemeToImage LeeAddShadowImage; -/** 添加选中图片设置 -> 格式: .LeeAddSelectedImage(@@"tag" , UIImage 或 @"imageName" 或 @"imagePath") */ +/** 添加选中图片设置 -> 格式: .LeeAddSelectedImage(@@"tag" , UIImage 或 @@"imageName" 或 @@"imagePath") */ @property (nonatomic , copy , readonly ) LEEConfigThemeToImage LeeAddSelectedImage; -/** 添加背景图片设置 -> 格式: .LeeAddBackgroundImage(@@"tag" , UIImage 或 @"imageName" 或 @"imagePath") */ +/** 添加背景图片设置 -> 格式: .LeeAddBackgroundImage(@@"tag" , UIImage 或 @@"imageName" 或 @@"imagePath") */ @property (nonatomic , copy , readonly ) LEEConfigThemeToImage LeeAddBackgroundImage; -/** 添加返回指示图片设置 -> 格式: .LeeAddBackIndicatorImage(@@"tag" , UIImage 或 @"imageName" 或 @"imagePath") */ +/** 添加返回指示图片设置 -> 格式: .LeeAddBackIndicatorImage(@@"tag" , UIImage 或 @@"imageName" 或 @@"imagePath") */ @property (nonatomic , copy , readonly ) LEEConfigThemeToImage LeeAddBackIndicatorImage; -/** 添加返回指示图片设置 -> 格式: .LeeAddBackIndicatorTransitionMaskImage(@@"tag" , UIImage 或 @"imageName" 或 @"imagePath") */ +/** 添加返回指示图片设置 -> 格式: .LeeAddBackIndicatorTransitionMaskImage(@@"tag" , UIImage 或 @@"imageName" 或 @@"imagePath") */ @property (nonatomic , copy , readonly ) LEEConfigThemeToImage LeeAddBackIndicatorTransitionMaskImage; -/** 添加选择指示器图片设置 -> 格式: .LeeAddSelectionIndicatorImage(@@"tag" , UIImage 或 @"imageName" 或 @"imagePath") */ +/** 添加选择指示器图片设置 -> 格式: .LeeAddSelectionIndicatorImage(@@"tag" , UIImage 或 @@"imageName" 或 @@"imagePath") */ @property (nonatomic , copy , readonly ) LEEConfigThemeToImage LeeAddSelectionIndicatorImage; -/** 添加分栏背景图片设置 -> 格式: .LeeAddScopeBarBackgroundImage(@@"tag" , UIImage 或 @"imageName" 或 @"imagePath") */ +/** 添加分栏背景图片设置 -> 格式: .LeeAddScopeBarBackgroundImage(@@"tag" , UIImage 或 @@"imageName" 或 @@"imagePath") */ @property (nonatomic , copy , readonly ) LEEConfigThemeToImage LeeAddScopeBarBackgroundImage; /** 添加按钮图片设置 -> 格式: .LeeAddButtonImage(@@"tag" , UIImage , UIControlStateNormal) */ @property (nonatomic , copy , readonly ) LEEConfigThemeToImageAndState LeeAddButtonImage; /** 添加按钮背景图片设置 -> 格式: .LeeAddButtonBackgroundImage(@@"tag" , UIImage , UIControlStateNormal) */ @property (nonatomic , copy , readonly ) LEEConfigThemeToImageAndState LeeAddButtonBackgroundImage; -/** 添加属性图片设置 -> 格式: .LeeAddKeyPathAndImage(@@"tag" , @"keyPath" , UIImage 或 @"imageName" 或 @"imagePath") */ +/** 添加属性图片设置 -> 格式: .LeeAddKeyPathAndImage(@@"tag" , @@"keyPath" , UIImage 或 @"imageName" 或 @"imagePath") */ @property (nonatomic , copy , readonly ) LEEConfigThemeToKeyPathAndImage LeeAddKeyPathAndImage; /** ----JSON设置方式---- */ /** Block */ -/** 自定义设置 -> 格式: .LeeCustomConfig(@@"identifier" , ^(id value){ code... }) */ -@property (nonatomic , copy , readonly ) LEEConfigThemeToStringAndBlock LeeCustomConfig; +/** 自定义设置 -> 格式: .LeeCustomConfig(@@"identifier" , ^(id item , id value){ code... }) */ +@property (nonatomic , copy , readonly ) LEEConfigThemeToIdentifierAndBlock LeeCustomConfig; /** Color */ @@ -204,6 +214,10 @@ typedef LEEThemeConfigModel *(^LEEConfigThemeToKeyPathAndString)(NSString *tag , @property (nonatomic , copy , readonly ) LEEConfigThemeToIdentifier LeeConfigBackgroundColor; /** 设置占位符颜色标识符 -> 格式: .LeeConfigPlaceholderColor(@@"identifier") */ @property (nonatomic , copy , readonly ) LEEConfigThemeToIdentifier LeeConfigPlaceholderColor; +/** 设置进度轨道渲染颜色标识符 -> 格式: .LeeConfigTrackTintColor(@@"identifier") */ +@property (nonatomic , copy , readonly ) LEEConfigThemeToIdentifier LeeConfigTrackTintColor; +/** 设置进度渲染颜色标识符 -> 格式: .LeeConfigProgressTintColor(@@"identifier") */ +@property (nonatomic , copy , readonly ) LEEConfigThemeToIdentifier LeeConfigProgressTintColor; /** 设置高亮文本颜色标识符 -> 格式: .LeeConfigHighlightedTextColor(@@"identifier") */ @property (nonatomic , copy , readonly ) LEEConfigThemeToIdentifier LeeConfigHighlightedTextColor; /** 设置页数指示渲染颜色标识符 -> 格式: .LeeConfigPageIndicatorTintColor(@@"identifier") */ @@ -219,6 +233,10 @@ typedef LEEThemeConfigModel *(^LEEConfigThemeToKeyPathAndString)(NSString *tag , /** 设置图片标识符 -> 格式: .LeeConfigImage(@@"identifier") */ @property (nonatomic , copy , readonly ) LEEConfigThemeToIdentifier LeeConfigImage; +/** 设置进度轨道图片标识符 -> 格式: .LeeConfigTrackImage(@@"identifier") */ +@property (nonatomic , copy , readonly ) LEEConfigThemeToIdentifier LeeConfigTrackImage; +/** 设置进度图片标识符 -> 格式: .LeeConfigProgressImage(@@"identifier") */ +@property (nonatomic , copy , readonly ) LEEConfigThemeToIdentifier LeeConfigProgressImage; /** 设置阴影图片标识符 -> 格式: .LeeConfigShadowImage(@@"identifier") */ @property (nonatomic , copy , readonly ) LEEConfigThemeToIdentifier LeeConfigShadowImage; /** 设置选中图片标识符 -> 格式: .LeeConfigSelectedImage(@@"identifier") */ @@ -238,7 +256,12 @@ typedef LEEThemeConfigModel *(^LEEConfigThemeToKeyPathAndString)(NSString *tag , /** 设置按钮背景图片标识符 -> 格式: .LeeConfigButtonBackgroundImage(@@"identifier" , UIControlStateNormal) */ @property (nonatomic , copy , readonly ) LEEConfigThemeToIdentifierAndState LeeConfigButtonBackgroundImage; -/** 设置主题更改过渡动画时长 -> 格式: .LeeChangeThemeAnimationDuration(0.2f) */ +/** 设置属性标识符 -> 格式: .LeeAddKeyPathAndColor(@@"keyPath" , @@"identifier") */ +@property (nonatomic , copy , readonly ) LEEConfigThemeToString LeeAddKeyPathAndIdentifier; + +/** ----通用设置---- */ + +/** 设置主题更改过渡动画时长 -> 格式: .LeeChangeThemeAnimationDuration(0.1f) */ @property (nonatomic , copy , readonly ) LEEConfigThemeToFloat LeeChangeThemeAnimationDuration; @end diff --git a/LEEThemeDemo/LEEThemeDemo/LEETheme/LEETheme.m b/LEEThemeDemo/LEEThemeDemo/LEETheme/LEETheme.m index 2d2159d..8cbf7bf 100644 --- a/LEEThemeDemo/LEEThemeDemo/LEETheme/LEETheme.m +++ b/LEEThemeDemo/LEEThemeDemo/LEETheme/LEETheme.m @@ -12,7 +12,7 @@ * * @author LEE * @copyright Copyright © 2016年 lee. All rights reserved. - * @version V1.0.3 + * @version V1.0.4 */ @@ -407,6 +407,28 @@ - (LEEConfigThemeToColor)LeeAddPlaceholderColor{ } +- (LEEConfigThemeToColor)LeeAddTrackTintColor{ + + __weak typeof(self) weakSelf = self; + + return ^(NSString *tag , UIColor *color){ + + return weakSelf.LeeAddKeyPathAndColor(tag , @"trackTintColor" , color); + }; + +} + +- (LEEConfigThemeToColor)LeeAddProgressTintColor{ + + __weak typeof(self) weakSelf = self; + + return ^(NSString *tag , UIColor *color){ + + return weakSelf.LeeAddKeyPathAndColor(tag , @"progressTintColor" , color); + }; + +} + - (LEEConfigThemeToColor)LeeAddHighlightedTextColor{ __weak typeof(self) weakSelf = self; @@ -520,6 +542,28 @@ - (LEEConfigThemeToImage)LeeAddImage{ } +- (LEEConfigThemeToImage)LeeAddTrackImage{ + + __weak typeof(self) weakSelf = self; + + return ^(NSString *tag , id image){ + + return weakSelf.LeeAddKeyPathAndImage(tag , @"trackImage" , image); + }; + +} + +- (LEEConfigThemeToImage)LeeAddProgressImage{ + + __weak typeof(self) weakSelf = self; + + return ^(NSString *tag , id image){ + + return weakSelf.LeeAddKeyPathAndImage(tag , @"progressImage" , image); + }; + +} + - (LEEConfigThemeToImage)LeeAddShadowImage{ __weak typeof(self) weakSelf = self; @@ -645,11 +689,11 @@ - (LEEConfigThemeToImageAndState)LeeAddButtonBackgroundImage{ #pragma mark ***JSON设置方式*** -- (LEEConfigThemeToStringAndBlock)LeeCustomConfig{ +- (LEEConfigThemeToIdentifierAndBlock)LeeCustomConfig{ __weak typeof(self) weakSelf = self; - return ^(NSString *identifier , LEEThemeConfigBlock configBlock){ + return ^(NSString *identifier , LEEThemeConfigBlockToIdentifier configBlock){ NSMutableDictionary *info = weakSelf.modelThemeIdentifierConfigInfo[@(LEEThemeIdentifierConfigTypeCustomConfig)]; @@ -672,11 +716,7 @@ - (LEEConfigThemeToIdentifier)LeeConfigTintColor{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"tintColor"]; - - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; - - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"tintColor" , identifier); }; } @@ -687,11 +727,7 @@ - (LEEConfigThemeToIdentifier)LeeConfigTextColor{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"textColor"]; - - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; - - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"textColor" , identifier); }; } @@ -702,11 +738,7 @@ - (LEEConfigThemeToIdentifier)LeeConfigFillColor{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"fillColor"]; - - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; - - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"fillColor" , identifier); }; } @@ -717,11 +749,7 @@ - (LEEConfigThemeToIdentifier)LeeConfigStrokeColor{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"strokeColor"]; - - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; - - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"strokeColor" , identifier); }; } @@ -732,11 +760,7 @@ - (LEEConfigThemeToIdentifier)LeeConfigBorderColor{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"borderColor"]; - - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; - - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"borderColor" , identifier); }; } @@ -747,11 +771,7 @@ - (LEEConfigThemeToIdentifier)LeeConfigShadowColor{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"shadowColor"]; - - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; - - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"shadowColor" , identifier); }; } @@ -762,11 +782,7 @@ - (LEEConfigThemeToIdentifier)LeeConfigOnTintColor{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"onTintColor"]; - - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; - - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"onTintColor" , identifier); }; } @@ -777,11 +793,7 @@ - (LEEConfigThemeToIdentifier)LeeConfigThumbTintColor{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"thumbTintColor"]; - - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; - - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"thumbTintColor" , identifier); }; } @@ -792,11 +804,7 @@ - (LEEConfigThemeToIdentifier)LeeConfigSeparatorColor{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"separatorColor"]; - - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; - - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"separatorColor" , identifier); }; } @@ -807,11 +815,7 @@ - (LEEConfigThemeToIdentifier)LeeConfigBarTintColor{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"barTintColor"]; - - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; - - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"barTintColor" , identifier); }; } @@ -822,11 +826,7 @@ - (LEEConfigThemeToIdentifier)LeeConfigBackgroundColor{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"backgroundColor"]; - - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; - - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"backgroundColor" , identifier); }; } @@ -837,11 +837,29 @@ - (LEEConfigThemeToIdentifier)LeeConfigPlaceholderColor{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"_placeholderLabel.textColor"]; + return weakSelf.LeeAddKeyPathAndIdentifier(@"_placeholderLabel.textColor" , identifier); + }; + +} + +- (LEEConfigThemeToIdentifier)LeeConfigTrackTintColor{ + + __weak typeof(self) weakSelf = self; + + return ^(NSString *identifier){ - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; + return weakSelf.LeeAddKeyPathAndIdentifier(@"trackTintColor" , identifier); + }; + +} + +- (LEEConfigThemeToIdentifier)LeeConfigProgressTintColor{ + + __weak typeof(self) weakSelf = self; + + return ^(NSString *identifier){ - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"progressTintColor" , identifier); }; } @@ -852,11 +870,7 @@ - (LEEConfigThemeToIdentifier)LeeConfigHighlightedTextColor{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"highlightedTextColor"]; - - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; - - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"highlightedTextColor" , identifier); }; } @@ -867,11 +881,7 @@ - (LEEConfigThemeToIdentifier)LeeConfigPageIndicatorTintColor{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"pageIndicatorTintColor"]; - - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; - - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"pageIndicatorTintColor" , identifier); }; } @@ -882,11 +892,7 @@ - (LEEConfigThemeToIdentifier)LeeConfigCurrentPageIndicatorTintColor{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"currentPageIndicatorTintColor"]; - - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; - - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"currentPageIndicatorTintColor" , identifier); }; } @@ -939,11 +945,29 @@ - (LEEConfigThemeToIdentifier)LeeConfigImage{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"image"]; + return weakSelf.LeeAddKeyPathAndIdentifier(@"image" , identifier); + }; + +} + +- (LEEConfigThemeToIdentifier)LeeConfigTrackImage{ + + __weak typeof(self) weakSelf = self; + + return ^(NSString *identifier){ - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; + return weakSelf.LeeAddKeyPathAndIdentifier(@"trackImage" , identifier); + }; + +} + +- (LEEConfigThemeToIdentifier)LeeConfigProgressImage{ + + __weak typeof(self) weakSelf = self; + + return ^(NSString *identifier){ - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"progressImage" , identifier); }; } @@ -954,11 +978,7 @@ - (LEEConfigThemeToIdentifier)LeeConfigShadowImage{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"shadowImage"]; - - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; - - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"shadowImage" , identifier); }; } @@ -969,11 +989,7 @@ - (LEEConfigThemeToIdentifier)LeeConfigSelectedImage{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"selectedImage"]; - - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; - - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"selectedImage" , identifier); }; } @@ -984,11 +1000,7 @@ - (LEEConfigThemeToIdentifier)LeeConfigBackgroundImage{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"backgroundImage"]; - - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; - - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"backgroundImage" , identifier); }; } @@ -999,11 +1011,7 @@ - (LEEConfigThemeToIdentifier)LeeConfigBackIndicatorImage{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"backIndicatorImage"]; - - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; - - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"backIndicatorImage" , identifier); }; } @@ -1014,11 +1022,7 @@ - (LEEConfigThemeToIdentifier)LeeConfigBackIndicatorTransitionMaskImage{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"backIndicatorTransitionMaskImage"]; - - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; - - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"backIndicatorTransitionMaskImage" , identifier); }; } @@ -1029,11 +1033,7 @@ - (LEEConfigThemeToIdentifier)LeeConfigSelectionIndicatorImage{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"selectionIndicatorImage"]; - - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; - - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"selectionIndicatorImage" , identifier); }; } @@ -1044,11 +1044,7 @@ - (LEEConfigThemeToIdentifier)LeeConfigScopeBarBackgroundImage{ return ^(NSString *identifier){ - [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:@"scopeBarBackgroundImage"]; - - [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; - - return weakSelf; + return weakSelf.LeeAddKeyPathAndIdentifier(@"scopeBarBackgroundImage" , identifier); }; } @@ -1095,6 +1091,21 @@ - (LEEConfigThemeToIdentifierAndState)LeeConfigButtonBackgroundImage{ } +- (LEEConfigThemeToString)LeeAddKeyPathAndIdentifier{ + + __weak typeof(self) weakSelf = self; + + return ^(NSString *keyPath , NSString *identifier){ + + [weakSelf.modelThemeIdentifierConfigInfo setObject:identifier forKey:keyPath]; + + [weakSelf initCurrentThemeConfigHandleWithIdentifier:identifier]; + + return weakSelf; + }; + +} + - (LEEConfigThemeToFloat)LeeChangeThemeAnimationDuration{ __weak typeof(self) weakSelf = self; @@ -1301,11 +1312,13 @@ - (void)changeThemeConfigWithAboutConfigBlock:(void (^)())aboutConfigBlock{ if ([image isKindOfClass:[NSString class]]) { + NSString *info = image; + image = [UIImage imageNamed:image]; - if (!image) image = [UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:image]]; + if (!image) image = [UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:info]]; - if (!image) image = [UIImage imageWithContentsOfFile:image]; + if (!image) image = [UIImage imageWithContentsOfFile:info]; } if (image) if ([image isKindOfClass:[UIImage class]]) [self setValue:image forKeyPath:keyPath]; @@ -1330,9 +1343,9 @@ - (void)changeThemeConfigWithAboutConfigBlock:(void (^)())aboutConfigBlock{ for (NSString *identifier in identifierConfigInfo.allKeys) { - LEEThemeConfigBlock configBlockItem = identifierConfigInfo[identifier]; + LEEThemeConfigBlockToIdentifier configBlockItem = identifierConfigInfo[identifier]; - if (configBlockItem) configBlockItem([self getCurrentThemeTagValueWithIdentifier:identifier]); + if (configBlockItem) configBlockItem(self , [self getCurrentThemeTagValueWithIdentifier:identifier]); } } diff --git a/LEEThemeDemo/LEEThemeDemo/ViewController.m b/LEEThemeDemo/LEEThemeDemo/ViewController.m index 9e22af9..f099b39 100644 --- a/LEEThemeDemo/LEEThemeDemo/ViewController.m +++ b/LEEThemeDemo/LEEThemeDemo/ViewController.m @@ -150,6 +150,12 @@ - (void)initSubviews{ .LeeAddCurrentPageIndicatorTintColor(GRAY , [UIColor greenColor]); [self.view addSubview:pageControl]; +// button1.lee_theme.LeeCustomConfig(@"ident6" , ^(UIButton *item , id value){ +// +// item.alpha = [value floatValue]; +// +// }); + } #pragma mark - 设置主题样式 diff --git a/LEEThemeDemo/LEEThemeDemo/tag_blue_json.json b/LEEThemeDemo/LEEThemeDemo/tag_blue_json.json index 2595e50..8ee5575 100644 --- a/LEEThemeDemo/LEEThemeDemo/tag_blue_json.json +++ b/LEEThemeDemo/LEEThemeDemo/tag_blue_json.json @@ -9,6 +9,6 @@ }, "other": { "ident5": "321", - "ident6": "000" + "ident6": "0.3" } } \ No newline at end of file diff --git a/LEEThemeDemo/LEEThemeDemo/tag_gray_json.json b/LEEThemeDemo/LEEThemeDemo/tag_gray_json.json index 741ddc2..ab8c153 100644 --- a/LEEThemeDemo/LEEThemeDemo/tag_gray_json.json +++ b/LEEThemeDemo/LEEThemeDemo/tag_gray_json.json @@ -6,5 +6,9 @@ "image": { "ident3": "picImage.jpg", "ident4": "huajis.jpg" + }, + "other": { + "ident5": "321", + "ident6": "0.5" } } \ No newline at end of file diff --git a/LEEThemeDemo/LEEThemeDemo/tag_green_json.json b/LEEThemeDemo/LEEThemeDemo/tag_green_json.json index 2c98dc9..52c6493 100644 --- a/LEEThemeDemo/LEEThemeDemo/tag_green_json.json +++ b/LEEThemeDemo/LEEThemeDemo/tag_green_json.json @@ -9,6 +9,6 @@ }, "other": { "ident5": "321", - "ident6": "000" + "ident6": "0" } } \ No newline at end of file diff --git a/LEEThemeDemo/LEEThemeDemo/tag_red_json.json b/LEEThemeDemo/LEEThemeDemo/tag_red_json.json index cb984bd..c62a8b5 100644 --- a/LEEThemeDemo/LEEThemeDemo/tag_red_json.json +++ b/LEEThemeDemo/LEEThemeDemo/tag_red_json.json @@ -9,6 +9,6 @@ }, "other": { "ident5": "1234", - "ident6": "111" + "ident6": "1.0" } } \ No newline at end of file