1010#import " QMUICommonDefines.h"
1111#import " QMUIConfiguration.h"
1212#import " UIImage+QMUI.h"
13+ #import " QMUIButton.h"
14+ #import " QMUITabBarViewController.h"
1315
1416@implementation QMUIConfigurationManager
1517
@@ -31,10 +33,9 @@ - (instancetype)init {
3133
3234#pragma mark - 初始化默认值
3335
34- - (void )initDefaultConfiguration
35- {
36+ - (void )initDefaultConfiguration {
3637
37- #pragma mark - Global Color
38+ #pragma mark - Global Color
3839
3940 self.clearColor = [UIColor colorWithRed: 1 green: 1 blue: 1 alpha: 0 ];
4041 self.whiteColor = [UIColor colorWithRed: 1 green: 1 blue: 1 alpha: 1 ];
@@ -46,7 +47,7 @@ - (void)initDefaultConfiguration
4647 self.greenColor = UIColorMake (79 , 214 , 79 );
4748 self.blueColor = UIColorMake (43 , 133 , 208 );
4849 self.yellowColor = UIColorMake (255 , 252 , 233 );
49-
50+
5051 self.linkColor = UIColorMake (56 , 116 , 171 );
5152 self.disabledColor = self.grayColor ;
5253 self.backgroundColor = UIColorMake (246 , 246 , 246 );
@@ -60,13 +61,13 @@ - (void)initDefaultConfiguration
6061 self.testColorGreen = UIColorMakeWithRGBA (0 , 255 , 0 , .3 );
6162 self.testColorBlue = UIColorMakeWithRGBA (0 , 0 , 255 , .3 );
6263
63- #pragma mark - UIWindowLevel
64+ #pragma mark - UIWindowLevel
6465 self.windowLevelQMUIAlertView = UIWindowLevelAlert - 4.0 ;
6566 self.windowLevelQMUIActionSheet = UIWindowLevelAlert - 4.0 ;
6667 self.windowLevelQMUIMoreOperationController = UIWindowLevelStatusBar + 1 ;
6768 self.windowLevelQMUIImagePreviewView = UIWindowLevelStatusBar + 1 ;
6869
69- #pragma mark - UIControl
70+ #pragma mark - UIControl
7071
7172 self.controlHighlightedAlpha = 0 .5f ;
7273 self.controlDisabledAlpha = 0 .5f ;
@@ -75,7 +76,7 @@ - (void)initDefaultConfiguration
7576 self.segmentTextSelectedTintColor = self.whiteColor ;
7677 self.segmentFontSize = UIFontMake (13 );
7778
78- #pragma mark - UIButton
79+ #pragma mark - UIButton
7980
8081 self.buttonHighlightedAlpha = self.controlHighlightedAlpha ;
8182 self.buttonDisabledAlpha = self.controlDisabledAlpha ;
@@ -93,20 +94,20 @@ - (void)initDefaultConfiguration
9394 self.fillButtonColorGray = self.grayColor ;
9495 self.fillButtonColorWhite = self.whiteColor ;
9596
96- #pragma mark - UITextField & UITextView
97+ #pragma mark - UITextField & UITextView
9798
9899 self.textFieldTintColor = UIColorBlue;
99100 self.textFieldTextInsets = UIEdgeInsetsMake (0 , 7 , 0 , 7 );
100101
101- #pragma mark - ActionSheet
102+ #pragma mark - ActionSheet
102103
103104 self.actionSheetButtonTintColor = self.blueColor ;
104105 self.actionSheetButtonBackgroundColor = UIColorMake (255 , 255 , 255 );
105106 self.actionSheetButtonBackgroundColorHighlighted = UIColorMake (235 , 235 , 235 );
106107 self.actionSheetButtonFont = UIFontMake (21 );
107108 self.actionSheetButtonFontBold = UIFontBoldMake (21 );
108109
109- #pragma mark - NavigationBar
110+ #pragma mark - NavigationBar
110111
111112 self.navBarHighlightedAlpha = 0 .2f ;
112113 self.navBarDisabledAlpha = 0 .2f ;
@@ -130,7 +131,7 @@ - (void)initDefaultConfiguration
130131 self.navBarActivityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
131132 self.navBarAccessoryViewTypeDisclosureIndicatorImage = [[UIImage imageWithShape: QMUIImageShapeTriangle size: CGSizeMake (8 , 5 ) tintColor: self .whiteColor] imageWithOrientation: UIImageOrientationDown];
132133
133- #pragma mark - TabBar
134+ #pragma mark - TabBar
134135
135136 self.tabBarBackgroundImage = nil ;
136137 self.tabBarBarTintColor = nil ;
@@ -139,7 +140,7 @@ - (void)initDefaultConfiguration
139140 self.tabBarItemTitleColor = UIColorMake (119 , 119 , 119 );
140141 self.tabBarItemTitleColorSelected = self.tabBarTintColor ;
141142
142- #pragma mark - Toolbar
143+ #pragma mark - Toolbar
143144
144145 self.toolBarHighlightedAlpha = 0 .4f ;
145146 self.toolBarDisabledAlpha = 0 .4f ;
@@ -151,7 +152,7 @@ - (void)initDefaultConfiguration
151152 self.toolBarShadowImageColor = UIColorMake (178 , 178 , 178 );
152153 self.toolBarButtonFont = UIFontMake (17 );
153154
154- #pragma mark - SearchBar
155+ #pragma mark - SearchBar
155156
156157 self.searchBarTextFieldBackground = self.whiteColor ;
157158 self.searchBarTextFieldBorderColor = UIColorMake (205 , 208 , 210 );
@@ -164,7 +165,7 @@ - (void)initDefaultConfiguration
164165 self.searchBarClearIconImage = nil ;
165166 self.searchBarTextFieldCornerRadius = 2.0 ;
166167
167- #pragma mark - TableView / TableViewCell
168+ #pragma mark - TableView / TableViewCell
168169
169170 self.tableViewBackgroundColor = self.whiteColor ;
170171 self.tableViewGroupedBackgroundColor = self.backgroundColor ;
@@ -204,7 +205,7 @@ - (void)initDefaultConfiguration
204205 self.tableViewCellContentDefaultPaddingLeft = 15 ;
205206 self.tableViewCellContentDefaultPaddingRight = 10 ;
206207
207- #pragma mark - Others
208+ #pragma mark - Others
208209
209210 self.supportedOrientationMask = UIInterfaceOrientationMaskPortrait;
210211 self.statusbarStyleLightInitially = NO ;
@@ -213,3 +214,38 @@ - (void)initDefaultConfiguration
213214}
214215
215216@end
217+
218+ @implementation QMUIConfigurationManager (UIAppearance)
219+
220+ + (void )renderGlobalAppearances {
221+
222+ // QMUIButton
223+ [QMUINavigationButton renderNavigationButtonAppearanceStyle ];
224+ [QMUIToolbarButton renderToolbarButtonAppearanceStyle ];
225+
226+ // UINavigationBar
227+ UINavigationBar *navigationBarAppearance = [UINavigationBar appearance ];
228+ [navigationBarAppearance setBarTintColor: NavBarBarTintColor];
229+ [navigationBarAppearance setBackgroundImage: NavBarBackgroundImage forBarMetrics: UIBarMetricsDefault];
230+ [navigationBarAppearance setShadowImage: NavBarShadowImage];
231+
232+ // UIToolBar
233+ UIToolbar *toolBarAppearance = [UIToolbar appearance ];
234+ [toolBarAppearance setBarTintColor: ToolBarBarTintColor];
235+ [toolBarAppearance setBackgroundImage: ToolBarBackgroundImage forToolbarPosition: UIBarPositionAny barMetrics: UIBarMetricsDefault];
236+ [toolBarAppearance setShadowImage: [UIImage imageWithColor: ToolBarShadowImageColor size: CGSizeMake (1 , PixelOne) cornerRadius: 0 ] forToolbarPosition: UIBarPositionAny];
237+
238+ // UITabBar
239+ UITabBar *tabBarAppearance = [UITabBar appearance ];
240+ [tabBarAppearance setBarTintColor: TabBarBarTintColor];
241+ [tabBarAppearance setBackgroundImage: TabBarBackgroundImage];
242+ [tabBarAppearance setShadowImage: [UIImage imageWithColor: TabBarShadowImageColor size: CGSizeMake (1 , PixelOne) cornerRadius: 0 ]];
243+
244+
245+ // UITabBarItem
246+ UITabBarItem *tabBarItemAppearance = [UITabBarItem appearanceWhenContainedIn: [QMUITabBarViewController class ], nil ];
247+ [tabBarItemAppearance setTitleTextAttributes: @{NSForegroundColorAttributeName :TabBarItemTitleColor} forState: UIControlStateNormal];
248+ [tabBarItemAppearance setTitleTextAttributes: @{NSForegroundColorAttributeName :TabBarItemTitleColorSelected} forState: UIControlStateSelected];
249+ }
250+
251+ @end
0 commit comments