Skip to content

Commit b96210e

Browse files
committed
Merge commit '50c73b3d4026da589a404f905d8d54d3a9917af1'
2 parents 881bad5 + 50c73b3 commit b96210e

10 files changed

Lines changed: 251 additions & 228 deletions

QMUI/QMUIKit/UICommon/QMUIConfiguration.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/*
1313
* 定义宏,宏的值是通过QMUIConfigurationManager的单例来获取属性的值。
1414
* 如果项目需要修改根据项目来修改某些宏的名字,请通过QMUIConfigurationManager来修改相应的属性,然后在项目启动的地方调用。
15-
* @waining 如果需要增加一个宏,则需要定义一个新的QMUIConfigurationManager属性。(具体请联系zhoonchen/molicechen)
15+
* @waining 如果需要增加一个宏,则需要定义一个新的QMUIConfigurationManager属性。
1616
*/
1717

1818

@@ -56,10 +56,6 @@
5656
#define UIControlHighlightedAlpha [QMUICMI controlHighlightedAlpha] // 一般control的Highlighted透明值
5757
#define UIControlDisabledAlpha [QMUICMI controlDisabledAlpha] // 一般control的Disable透明值
5858

59-
#define SegmentTextTintColor [QMUICMI segmentTextTintColor] // segment的tintColor
60-
#define SegmentTextSelectedTintColor [QMUICMI segmentTextSelectedTintColor] // segment选中态的tintColor
61-
#define SegmentFontSize [QMUICMI segmentFontSize] // segment的字体大小
62-
6359
// 按钮
6460
#pragma mark - UIButton
6561
#define ButtonHighlightedAlpha [QMUICMI buttonHighlightedAlpha] // 按钮Highlighted状态的透明度
@@ -83,14 +79,6 @@
8379
#define TextFieldTintColor [QMUICMI textFieldTintColor] // 全局UITextField、UITextView的tintColor
8480
#define TextFieldTextInsets [QMUICMI textFieldTextInsets] // QMUITextField的内边距
8581

86-
#pragma mark - ActionSheet
87-
88-
#define ActionSheetButtonTintColor [QMUICMI actionSheetButtonTintColor]
89-
#define ActionSheetButtonBackgroundColor [QMUICMI actionSheetButtonBackgroundColor]
90-
#define ActionSheetButtonBackgroundColorHighlighted [QMUICMI actionSheetButtonBackgroundColorHighlighted]
91-
#define ActionSheetButtonFont [QMUICMI actionSheetButtonFont]
92-
#define ActionSheetButtonFontBold [QMUICMI actionSheetButtonFontBold]
93-
9482

9583
#pragma mark - NavigationBar
9684

QMUI/QMUIKit/UICommon/QMUIConfigurationManager.h

Lines changed: 132 additions & 144 deletions
Large diffs are not rendered by default.

QMUI/QMUIKit/UICommon/QMUIConfigurationManager.m

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,11 @@ - (void)initDefaultConfiguration {
6161
self.testColorGreen = UIColorMakeWithRGBA(0, 255, 0, .3);
6262
self.testColorBlue = UIColorMakeWithRGBA(0, 0, 255, .3);
6363

64-
#pragma mark - UIWindowLevel
65-
self.windowLevelQMUIAlertView = UIWindowLevelAlert - 4.0;
66-
self.windowLevelQMUIActionSheet = UIWindowLevelAlert - 4.0;
67-
self.windowLevelQMUIMoreOperationController = UIWindowLevelStatusBar + 1;
68-
self.windowLevelQMUIImagePreviewView = UIWindowLevelStatusBar + 1;
69-
7064
#pragma mark - UIControl
7165

7266
self.controlHighlightedAlpha = 0.5f;
7367
self.controlDisabledAlpha = 0.5f;
7468

75-
self.segmentTextTintColor = self.blueColor;
76-
self.segmentTextSelectedTintColor = self.whiteColor;
77-
self.segmentFontSize = UIFontMake(13);
78-
7969
#pragma mark - UIButton
8070

8171
self.buttonHighlightedAlpha = self.controlHighlightedAlpha;
@@ -99,14 +89,6 @@ - (void)initDefaultConfiguration {
9989
self.textFieldTintColor = UIColorBlue;
10090
self.textFieldTextInsets = UIEdgeInsetsMake(0, 7, 0, 7);
10191

102-
#pragma mark - ActionSheet
103-
104-
self.actionSheetButtonTintColor = self.blueColor;
105-
self.actionSheetButtonBackgroundColor = UIColorMake(255, 255, 255);
106-
self.actionSheetButtonBackgroundColorHighlighted = UIColorMake(235, 235, 235);
107-
self.actionSheetButtonFont = UIFontMake(21);
108-
self.actionSheetButtonFontBold = UIFontBoldMake(21);
109-
11092
#pragma mark - NavigationBar
11193

11294
self.navBarHighlightedAlpha = 0.2f;
@@ -115,10 +97,9 @@ - (void)initDefaultConfiguration {
11597
self.navBarButtonFontBold = UIFontBoldMake(17);
11698
self.navBarBackgroundImage = nil;
11799
self.navBarShadowImage = nil;
118-
self.navBarShadowImageColor = UIColorMake(178, 178, 178);
119100
self.navBarBarTintColor = nil;
120101
self.navBarTintColor = self.blackColor;
121-
self.navBarTitleColor = nil;
102+
self.navBarTitleColor = self.navBarTintColor;
122103
self.navBarTitleFont = UIFontBoldMake(17);
123104
self.navBarBackButtonTitlePositionAdjustment = UIOffsetZero;
124105
self.navBarBackIndicatorImage = [UIImage qmui_imageWithShape:QMUIImageShapeNavBack size:CGSizeMake(12, 20) tintColor:self.navBarTintColor];
@@ -157,7 +138,7 @@ - (void)initDefaultConfiguration {
157138
self.searchBarBottomBorderColor = UIColorMake(205, 208, 210);
158139
self.searchBarBarTintColor = UIColorMake(247, 247, 247);
159140
self.searchBarTintColor = self.blueColor;
160-
self.searchBarTextColor = UIColorBlack;
141+
self.searchBarTextColor = self.blackColor;
161142
self.searchBarPlaceholderColor = self.placeholderColor;
162143
self.searchBarSearchIconImage = nil;
163144
self.searchBarClearIconImage = nil;
@@ -171,13 +152,18 @@ - (void)initDefaultConfiguration {
171152
self.tableSectionIndexBackgroundColor = self.clearColor;
172153
self.tableSectionIndexTrackingBackgroundColor = self.clearColor;
173154
self.tableViewSeparatorColor = self.separatorColor;
155+
156+
self.tableViewCellNormalHeight = 44;
157+
self.tableViewCellTitleLabelColor = self.blackColor;
158+
self.tableViewCellDetailLabelColor = self.grayColor;
159+
self.tableViewCellContentDefaultPaddingLeft = 15;
160+
self.tableViewCellContentDefaultPaddingRight = 10;
174161
self.tableViewCellBackgroundColor = self.whiteColor;
175162
self.tableViewCellSelectedBackgroundColor = UIColorMake(232, 232, 232);
176163
self.tableViewCellWarningBackgroundColor = self.yellowColor;
177-
self.tableViewCellNormalHeight = 44;
178-
179164
self.tableViewCellDisclosureIndicatorImage = [UIImage qmui_imageWithShape:QMUIImageShapeDisclosureIndicator size:CGSizeMake(8, 13) tintColor:UIColorMakeWithRGBA(0, 0, 0, .2)];
180165
self.tableViewCellCheckmarkImage = [UIImage qmui_imageWithShape:QMUIImageShapeCheckmark size:CGSizeMake(15, 12) tintColor:UIColorBlue];
166+
181167
self.tableViewSectionHeaderBackgroundColor = UIColorMake(244, 244, 244);
182168
self.tableViewSectionFooterBackgroundColor = UIColorMake(244, 244, 244);
183169
self.tableViewSectionHeaderFont = UIFontBoldMake(12);
@@ -198,10 +184,11 @@ - (void)initDefaultConfiguration {
198184
self.tableViewGroupedSectionHeaderContentInset = UIEdgeInsetsMake(16, 15, 8, 15);
199185
self.tableViewGroupedSectionFooterContentInset = UIEdgeInsetsMake(8, 15, 2, 15);
200186

201-
self.tableViewCellTitleLabelColor = self.blackColor;
202-
self.tableViewCellDetailLabelColor = self.grayColor;
203-
self.tableViewCellContentDefaultPaddingLeft = 15;
204-
self.tableViewCellContentDefaultPaddingRight = 10;
187+
#pragma mark - UIWindowLevel
188+
self.windowLevelQMUIAlertView = UIWindowLevelAlert - 4.0;
189+
self.windowLevelQMUIActionSheet = UIWindowLevelAlert - 4.0;
190+
self.windowLevelQMUIMoreOperationController = UIWindowLevelStatusBar + 1;
191+
self.windowLevelQMUIImagePreviewView = UIWindowLevelStatusBar + 1;
205192

206193
#pragma mark - Others
207194

@@ -225,26 +212,52 @@ + (void)renderGlobalAppearances {
225212
UINavigationBar *navigationBarAppearance = [UINavigationBar appearance];
226213
navigationBarAppearance.barTintColor = NavBarBarTintColor;
227214
navigationBarAppearance.shadowImage = NavBarShadowImage;
228-
navigationBarAppearance.titleTextAttributes = @{NSFontAttributeName: NavBarTitleFont, NSForegroundColorAttributeName: NavBarTitleColor};
229215
[navigationBarAppearance setBackgroundImage:NavBarBackgroundImage forBarMetrics:UIBarMetricsDefault];
230216

217+
UIFont *navigationBarTitleFont = NavBarTitleFont;
218+
UIColor *navigationBarTitleColor = NavBarTitleColor;
219+
if (navigationBarTitleFont || navigationBarTitleColor) {
220+
NSMutableDictionary<NSString *, id> *titleTextAttributes = [[NSMutableDictionary alloc] init];
221+
if (navigationBarTitleFont) {
222+
[titleTextAttributes setValue:navigationBarTitleFont forKey:NSFontAttributeName];
223+
}
224+
if (navigationBarTitleColor) {
225+
[titleTextAttributes setValue:navigationBarTitleColor forKey:NSForegroundColorAttributeName];
226+
}
227+
navigationBarAppearance.titleTextAttributes = titleTextAttributes;
228+
}
229+
231230
// UIToolBar
232231
UIToolbar *toolBarAppearance = [UIToolbar appearance];
233232
toolBarAppearance.barTintColor = ToolBarBarTintColor;
234233
[toolBarAppearance setBackgroundImage:ToolBarBackgroundImage forToolbarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
235-
[toolBarAppearance setShadowImage:[UIImage qmui_imageWithColor:ToolBarShadowImageColor size:CGSizeMake(1, PixelOne) cornerRadius:0] forToolbarPosition:UIBarPositionAny];
234+
235+
UIColor *toolbarShadowImageColor = ToolBarShadowImageColor;
236+
if (toolbarShadowImageColor) {
237+
[toolBarAppearance setShadowImage:[UIImage qmui_imageWithColor:toolbarShadowImageColor size:CGSizeMake(1, PixelOne) cornerRadius:0] forToolbarPosition:UIBarPositionAny];
238+
}
236239

237240
// UITabBar
238241
UITabBar *tabBarAppearance = [UITabBar appearance];
239242
tabBarAppearance.barTintColor = TabBarBarTintColor;
240243
tabBarAppearance.backgroundImage = TabBarBackgroundImage;
241-
[tabBarAppearance setShadowImage:[UIImage qmui_imageWithColor:TabBarShadowImageColor size:CGSizeMake(1, PixelOne) cornerRadius:0]];
242-
244+
UIColor *tabBarShadowImageColor = TabBarShadowImageColor;
245+
if (tabBarShadowImageColor) {
246+
[tabBarAppearance setShadowImage:[UIImage qmui_imageWithColor:tabBarShadowImageColor size:CGSizeMake(1, PixelOne) cornerRadius:0]];
247+
}
243248

244249
// UITabBarItem
245250
UITabBarItem *tabBarItemAppearance = [UITabBarItem appearance];
246-
[tabBarItemAppearance setTitleTextAttributes:@{NSForegroundColorAttributeName:TabBarItemTitleColor} forState:UIControlStateNormal];
247-
[tabBarItemAppearance setTitleTextAttributes:@{NSForegroundColorAttributeName:TabBarItemTitleColorSelected} forState:UIControlStateSelected];
251+
252+
UIColor *tabBarItemTitleColor = TabBarItemTitleColor;
253+
if (tabBarItemTitleColor) {
254+
[tabBarItemAppearance setTitleTextAttributes:@{NSForegroundColorAttributeName:tabBarItemTitleColor} forState:UIControlStateNormal];
255+
}
256+
257+
UIColor *tabBarItemTitleColorSelected = TabBarItemTitleColorSelected;
258+
if (tabBarItemTitleColorSelected) {
259+
[tabBarItemAppearance setTitleTextAttributes:@{NSForegroundColorAttributeName:tabBarItemTitleColorSelected} forState:UIControlStateSelected];
260+
}
248261
}
249262

250263
@end

QMUI/QMUIKit/UICommon/QMUIConfigurationTemplate.m

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ + (void)setupConfigurationTemplate {
6666
//- QMUICMI.controlHighlightedAlpha = 0.5f; // UIControlHighlightedAlpha : 全局的highlighted alpha值
6767
//- QMUICMI.controlDisabledAlpha = 0.5f; // UIControlDisabledAlpha : 全局的disabled alpha值
6868

69-
//- QMUICMI.segmentTextTintColor = UIColorBlue; // SegmentTextTintColor : segment的tintColor
70-
//- QMUICMI.segmentTextSelectedTintColor = UIColorWhite; // SegmentTextSelectedTintColor : segment选中态的tintColor
71-
//- QMUICMI.segmentFontSize = UIFontMake(13); // SegmentFontSize : segment的字体大小
72-
7369
#pragma mark - UIButton
7470
//- QMUICMI.buttonHighlightedAlpha = UIControlHighlightedAlpha; // ButtonHighlightedAlpha : 按钮的highlighted alpha值
7571
//- QMUICMI.buttonDisabledAlpha = UIControlDisabledAlpha; // ButtonDisabledAlpha : 按钮的disabled alpha值
@@ -92,13 +88,6 @@ + (void)setupConfigurationTemplate {
9288
//- QMUICMI.textFieldTintColor = UIColorBlue; // TextFieldTintColor : 全局UITextField、UITextView的tintColor
9389
//- QMUICMI.textFieldTextInsets = UIEdgeInsetsMake(0, 7, 0, 7); // TextFieldTextInsets : QMUITextField的内边距
9490

95-
#pragma mark - ActionSheet
96-
//- QMUICMI.actionSheetButtonTintColor = UIColorBlue; // ActionSheetButtonTintColor
97-
//- QMUICMI.actionSheetButtonBackgroundColor = UIColorMake(255, 255, 255); // ActionSheetButtonBackgroundColor
98-
//- QMUICMI.actionSheetButtonBackgroundColorHighlighted = UIColorMake(235, 235, 235); // ActionSheetButtonBackgroundColorHighlighted
99-
//- QMUICMI.actionSheetButtonFont = UIFontMake(21); // ActionSheetButtonFont
100-
//- QMUICMI.actionSheetButtonFontBold = UIFontBoldMake(21); // ActionSheetButtonFontBold
101-
10291
#pragma mark - NavigationBar
10392

10493
//- QMUICMI.navBarHighlightedAlpha = 0.2f; // NavBarHighlightedAlpha

QMUI/QMUIKit/UIKitExtensions/QMUIButton.m

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ - (void)didInitialized {
4343
self.adjustsImageTintColorAutomatically = NO;
4444
self.tintColor = ButtonTintColor;
4545
if (!self.adjustsTitleTintColorAutomatically) {
46-
[self setTitleColor:ButtonTintColor forState:UIControlStateNormal];
46+
[self setTitleColor:self.tintColor forState:UIControlStateNormal];
4747
}
4848

4949
// 默认接管highlighted和disabled的表现,去掉系统默认的表现
@@ -508,11 +508,15 @@ - (void)renderButtonStyle {
508508
}
509509
break;
510510
case QMUINavigationButtonTypeBack: {
511+
self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
511512
UIImage *backIndicatorImage = NavBarBackIndicatorImage;
513+
if (!backIndicatorImage) {
514+
QMUILog(@"NavBarBackIndicatorImage 为 nil,无法创建正确的 QMUINavigationButtonTypeBack 按钮");
515+
return;
516+
}
512517
[self setImage:backIndicatorImage forState:UIControlStateNormal];
513518
[self setImage:[backIndicatorImage qmui_imageWithAlpha:NavBarHighlightedAlpha] forState:UIControlStateHighlighted];
514519
[self setImage:[backIndicatorImage qmui_imageWithAlpha:NavBarDisabledAlpha] forState:UIControlStateDisabled];
515-
self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
516520
}
517521
break;
518522

@@ -748,9 +752,11 @@ - (void)renderButtonStyle {
748752
}
749753

750754
+ (void)renderToolbarButtonAppearanceStyle {
751-
// iOS7及以上默认使用系统自己的highlighted和disabled(及toolBar的tintColor),不使用ToolBarHighlightedAlpha和ToolBarDisabledAlpha
752-
UIBarButtonItem *barButtonItemAppearance = [UIBarButtonItem appearanceWhenContainedIn:QMUINavigationController.class, nil];
753-
[barButtonItemAppearance setTitleTextAttributes:@{NSFontAttributeName: ToolBarButtonFont} forState:UIControlStateNormal];
755+
UIFont *titleFont = ToolBarButtonFont;
756+
if (titleFont) {
757+
UIBarButtonItem *barButtonItemAppearance = [UIBarButtonItem appearanceWhenContainedIn:QMUINavigationController.class, nil];
758+
[barButtonItemAppearance setTitleTextAttributes:@{NSFontAttributeName: titleFont} forState:UIControlStateNormal];
759+
}
754760
}
755761

756762
+ (UIBarButtonItem *)barButtonItemWithToolbarButton:(QMUIToolbarButton *)button target:(id)target action:(SEL)selector {

QMUI/QMUIKit/UIKitExtensions/QMUISearchController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ - (void)showEmptyView {
283283
[super showEmptyView];
284284

285285
// 格式化样式,以适应当前项目的需求
286-
self.emptyView.backgroundColor = TableViewBackgroundColor;
286+
self.emptyView.backgroundColor = TableViewBackgroundColor ?: UIColorWhite;
287287
if ([self.searchResultsDelegate respondsToSelector:@selector(searchController:willShowEmptyView:)]) {
288288
[self.searchResultsDelegate searchController:self willShowEmptyView:self.emptyView];
289289
}

QMUI/QMUIKit/UIKitExtensions/QMUITableViewCell.m

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,12 @@ - (void)didInitializedWithStyle:(UITableViewCellStyle)style {
6262

6363
// iOS7下背景色默认白色,之前的版本背景色继承tableView,这里统一设置为白色
6464
self.backgroundColor = TableViewCellBackgroundColor;
65-
UIView *selectedBackgroundView = [[UIView alloc] init];
66-
selectedBackgroundView.backgroundColor = TableViewCellSelectedBackgroundColor;
67-
self.selectedBackgroundView = selectedBackgroundView;
65+
UIColor *selectedBackgroundColor = TableViewCellSelectedBackgroundColor;
66+
if (selectedBackgroundColor) {
67+
UIView *selectedBackgroundView = [[UIView alloc] init];
68+
selectedBackgroundView.backgroundColor = selectedBackgroundColor;
69+
self.selectedBackgroundView = selectedBackgroundView;
70+
}
6871

6972
// 因为在hitTest里扩大了accessoryView的响应范围,因此提高了系统一个与此相关的bug的出现几率,所以又在scrollView.delegate里做一些补丁性质的东西来修复
7073
if ([self.subviews.firstObject isKindOfClass:[UIScrollView class]]) {
@@ -184,19 +187,30 @@ - (void)initDefaultAccessoryImageViewIfNeeded {
184187
// 重写accessoryType,如果是UITableViewCellAccessoryDisclosureIndicator类型的,则使用 QMUIConfigurationTemplate.m 配置表里的图片
185188
- (void)setAccessoryType:(UITableViewCellAccessoryType)accessoryType {
186189
[super setAccessoryType:accessoryType];
190+
187191
if (accessoryType == UITableViewCellAccessoryDisclosureIndicator) {
188-
[self initDefaultAccessoryImageViewIfNeeded];
189-
self.defaultAccessoryImageView.image = TableViewCellDisclosureIndicatorImage;
190-
[self.defaultAccessoryImageView sizeToFit];
191-
self.accessoryView = self.defaultAccessoryImageView;
192-
} else if (accessoryType == UITableViewCellAccessoryCheckmark) {
193-
[self initDefaultAccessoryImageViewIfNeeded];
194-
self.defaultAccessoryImageView.image = TableViewCellCheckmarkImage;
195-
[self.defaultAccessoryImageView sizeToFit];
196-
self.accessoryView = self.defaultAccessoryImageView;
197-
} else {
198-
self.accessoryView = nil;
192+
UIImage *indicatorImage = TableViewCellDisclosureIndicatorImage;
193+
if (indicatorImage) {
194+
[self initDefaultAccessoryImageViewIfNeeded];
195+
self.defaultAccessoryImageView.image = TableViewCellDisclosureIndicatorImage;
196+
[self.defaultAccessoryImageView sizeToFit];
197+
self.accessoryView = self.defaultAccessoryImageView;
198+
return;
199+
}
199200
}
201+
202+
if (accessoryType == UITableViewCellAccessoryCheckmark) {
203+
UIImage *checkmarkImage = TableViewCellCheckmarkImage;
204+
if (checkmarkImage) {
205+
[self initDefaultAccessoryImageViewIfNeeded];
206+
self.defaultAccessoryImageView.image = TableViewCellCheckmarkImage;
207+
[self.defaultAccessoryImageView sizeToFit];
208+
self.accessoryView = self.defaultAccessoryImageView;
209+
return;
210+
}
211+
}
212+
213+
self.accessoryView = nil;
200214
}
201215

202216
#pragma mark - <UIScrollViewDelegate>

0 commit comments

Comments
 (0)