Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/QMUI/QMUI_iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoon committed Dec 27, 2016
2 parents 7c0c1e6 + c7f03f1 commit 81c482f
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 139 deletions.
2 changes: 0 additions & 2 deletions QMUIKit/QMUIKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ FOUNDATION_EXPORT const unsigned char QMUIKitVersionString[];
#import <QMUIKit/QMUIHelper.h>
#import <QMUIKit/QMUICommonDefines.h>
#import <QMUIKit/QMUIConfiguration.h>
#import <QMUIKit/QMUICommonUI.h>

/// QMUIKit
#import <QMUIKit/QMUIVisualEffectView.h>
Expand Down Expand Up @@ -114,7 +113,6 @@ FOUNDATION_EXPORT const unsigned char QMUIKitVersionString[];
#import "QMUIHelper.h"
#import "QMUICommonDefines.h"
#import "QMUIConfiguration.h"
#import "QMUICommonUI.h"

/// QMUIKit
#import "QMUIVisualEffectView.h"
Expand Down
21 changes: 0 additions & 21 deletions QMUIKit/UICommon/QMUICommonUI.h

This file was deleted.

52 changes: 0 additions & 52 deletions QMUIKit/UICommon/QMUICommonUI.m

This file was deleted.

10 changes: 9 additions & 1 deletion QMUIKit/UICommon/QMUIConfigurationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#import <UIKit/UIKit.h>

/**
* 维护项目全局 UI 配置的单例,通过业务项目自己的 QMUIConfigurationTemplate 来为这个单例赋值,而业务代码里则通过 q 文件里的宏来使用这些值。
* 维护项目全局 UI 配置的单例,通过业务项目自己的 QMUIConfigurationTemplate 来为这个单例赋值,而业务代码里则通过 QMUIConfiguration.h 文件里的宏来使用这些值。
*/
@interface QMUIConfigurationManager : NSObject

Expand Down Expand Up @@ -199,3 +199,11 @@
- (void)initDefaultConfiguration;

@end

@interface QMUIConfigurationManager (UIAppearance)

/**
* 设置全局 UIAppearance 的代码,一般在 `application:didFinishLaunchingWithOptions:` 里手动调用(在调用 `[QMUIConfigurationTemplate setupConfigurationTemplate]` 之后)
*/
+ (void)renderGlobalAppearances;
@end
66 changes: 51 additions & 15 deletions QMUIKit/UICommon/QMUIConfigurationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#import "QMUICommonDefines.h"
#import "QMUIConfiguration.h"
#import "UIImage+QMUI.h"
#import "QMUIButton.h"
#import "QMUITabBarViewController.h"

@implementation QMUIConfigurationManager

Expand All @@ -31,10 +33,9 @@ - (instancetype)init {

#pragma mark - 初始化默认值

- (void)initDefaultConfiguration
{
- (void)initDefaultConfiguration {

#pragma mark - Global Color
#pragma mark - Global Color

self.clearColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0];
self.whiteColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:1];
Expand All @@ -46,7 +47,7 @@ - (void)initDefaultConfiguration
self.greenColor = UIColorMake(79, 214, 79);
self.blueColor = UIColorMake(43, 133, 208);
self.yellowColor = UIColorMake(255, 252, 233);

self.linkColor = UIColorMake(56, 116, 171);
self.disabledColor = self.grayColor;
self.backgroundColor = UIColorMake(246, 246, 246);
Expand All @@ -60,13 +61,13 @@ - (void)initDefaultConfiguration
self.testColorGreen = UIColorMakeWithRGBA(0, 255, 0, .3);
self.testColorBlue = UIColorMakeWithRGBA(0, 0, 255, .3);

#pragma mark - UIWindowLevel
#pragma mark - UIWindowLevel
self.windowLevelQMUIAlertView = UIWindowLevelAlert - 4.0;
self.windowLevelQMUIActionSheet = UIWindowLevelAlert - 4.0;
self.windowLevelQMUIMoreOperationController = UIWindowLevelStatusBar + 1;
self.windowLevelQMUIImagePreviewView = UIWindowLevelStatusBar + 1;

#pragma mark - UIControl
#pragma mark - UIControl

self.controlHighlightedAlpha = 0.5f;
self.controlDisabledAlpha = 0.5f;
Expand All @@ -75,7 +76,7 @@ - (void)initDefaultConfiguration
self.segmentTextSelectedTintColor = self.whiteColor;
self.segmentFontSize = UIFontMake(13);

#pragma mark - UIButton
#pragma mark - UIButton

self.buttonHighlightedAlpha = self.controlHighlightedAlpha;
self.buttonDisabledAlpha = self.controlDisabledAlpha;
Expand All @@ -93,20 +94,20 @@ - (void)initDefaultConfiguration
self.fillButtonColorGray = self.grayColor;
self.fillButtonColorWhite = self.whiteColor;

#pragma mark - UITextField & UITextView
#pragma mark - UITextField & UITextView

self.textFieldTintColor = UIColorBlue;
self.textFieldTextInsets = UIEdgeInsetsMake(0, 7, 0, 7);

#pragma mark - ActionSheet
#pragma mark - ActionSheet

self.actionSheetButtonTintColor = self.blueColor;
self.actionSheetButtonBackgroundColor = UIColorMake(255, 255, 255);
self.actionSheetButtonBackgroundColorHighlighted = UIColorMake(235, 235, 235);
self.actionSheetButtonFont = UIFontMake(21);
self.actionSheetButtonFontBold = UIFontBoldMake(21);

#pragma mark - NavigationBar
#pragma mark - NavigationBar

self.navBarHighlightedAlpha = 0.2f;
self.navBarDisabledAlpha = 0.2f;
Expand All @@ -130,7 +131,7 @@ - (void)initDefaultConfiguration
self.navBarActivityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
self.navBarAccessoryViewTypeDisclosureIndicatorImage = [[UIImage imageWithShape:QMUIImageShapeTriangle size:CGSizeMake(8, 5) tintColor:self.whiteColor] imageWithOrientation:UIImageOrientationDown];

#pragma mark - TabBar
#pragma mark - TabBar

self.tabBarBackgroundImage = nil;
self.tabBarBarTintColor = nil;
Expand All @@ -139,7 +140,7 @@ - (void)initDefaultConfiguration
self.tabBarItemTitleColor = UIColorMake(119, 119, 119);
self.tabBarItemTitleColorSelected = self.tabBarTintColor;

#pragma mark - Toolbar
#pragma mark - Toolbar

self.toolBarHighlightedAlpha = 0.4f;
self.toolBarDisabledAlpha = 0.4f;
Expand All @@ -151,7 +152,7 @@ - (void)initDefaultConfiguration
self.toolBarShadowImageColor = UIColorMake(178, 178, 178);
self.toolBarButtonFont = UIFontMake(17);

#pragma mark - SearchBar
#pragma mark - SearchBar

self.searchBarTextFieldBackground = self.whiteColor;
self.searchBarTextFieldBorderColor = UIColorMake(205, 208, 210);
Expand All @@ -164,7 +165,7 @@ - (void)initDefaultConfiguration
self.searchBarClearIconImage = nil;
self.searchBarTextFieldCornerRadius = 2.0;

#pragma mark - TableView / TableViewCell
#pragma mark - TableView / TableViewCell

self.tableViewBackgroundColor = self.whiteColor;
self.tableViewGroupedBackgroundColor = self.backgroundColor;
Expand Down Expand Up @@ -204,7 +205,7 @@ - (void)initDefaultConfiguration
self.tableViewCellContentDefaultPaddingLeft = 15;
self.tableViewCellContentDefaultPaddingRight = 10;

#pragma mark - Others
#pragma mark - Others

self.supportedOrientationMask = UIInterfaceOrientationMaskPortrait;
self.statusbarStyleLightInitially = NO;
Expand All @@ -213,3 +214,38 @@ - (void)initDefaultConfiguration
}

@end

@implementation QMUIConfigurationManager (UIAppearance)

+ (void)renderGlobalAppearances {

// QMUIButton
[QMUINavigationButton renderNavigationButtonAppearanceStyle];
[QMUIToolbarButton renderToolbarButtonAppearanceStyle];

// UINavigationBar
UINavigationBar *navigationBarAppearance = [UINavigationBar appearance];
[navigationBarAppearance setBarTintColor:NavBarBarTintColor];
[navigationBarAppearance setBackgroundImage:NavBarBackgroundImage forBarMetrics:UIBarMetricsDefault];
[navigationBarAppearance setShadowImage:NavBarShadowImage];

// UIToolBar
UIToolbar *toolBarAppearance = [UIToolbar appearance];
[toolBarAppearance setBarTintColor:ToolBarBarTintColor];
[toolBarAppearance setBackgroundImage:ToolBarBackgroundImage forToolbarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
[toolBarAppearance setShadowImage:[UIImage imageWithColor:ToolBarShadowImageColor size:CGSizeMake(1, PixelOne) cornerRadius:0] forToolbarPosition:UIBarPositionAny];

// UITabBar
UITabBar *tabBarAppearance = [UITabBar appearance];
[tabBarAppearance setBarTintColor:TabBarBarTintColor];
[tabBarAppearance setBackgroundImage:TabBarBackgroundImage];
[tabBarAppearance setShadowImage:[UIImage imageWithColor:TabBarShadowImageColor size:CGSizeMake(1, PixelOne) cornerRadius:0]];


// UITabBarItem
UITabBarItem *tabBarItemAppearance = [UITabBarItem appearanceWhenContainedIn:[QMUITabBarViewController class], nil];
[tabBarItemAppearance setTitleTextAttributes:@{NSForegroundColorAttributeName:TabBarItemTitleColor} forState:UIControlStateNormal];
[tabBarItemAppearance setTitleTextAttributes:@{NSForegroundColorAttributeName:TabBarItemTitleColorSelected} forState:UIControlStateSelected];
}

@end
24 changes: 12 additions & 12 deletions QMUIKit/UICommon/QMUIConfigurationTemplate.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ + (void)setupConfigurationTemplate {

// === 修改配置值 === //

#pragma mark - Global Color
#pragma mark - Global Color

//- QMUICMI.clearColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0]; // UIColorClear
//- QMUICMI.whiteColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:1]; // UIColorWhite
Expand Down Expand Up @@ -59,7 +59,7 @@ + (void)setupConfigurationTemplate {
//- QMUICMI.testColorBlue = UIColorMakeWithRGBA(0, 0, 255, .3);


#pragma mark - UIControl
#pragma mark - UIControl

//- QMUICMI.controlDisabledAlpha = 0.5f; // UIControlHighlightedAlpha : 全局的highlighted alpha值
//- QMUICMI.controlDisabledAlpha = 0.5f; // UIControlDisabledAlpha : 全局的disabled alpha值
Expand All @@ -68,7 +68,7 @@ + (void)setupConfigurationTemplate {
//- QMUICMI.segmentTextSelectedTintColor = UIColorWhite; // SegmentTextSelectedTintColor : segment选中态的tintColor
//- QMUICMI.segmentFontSize = UIFontMake(13); // SegmentFontSize : segment的字体大小

#pragma mark - UIButton
#pragma mark - UIButton
//- QMUICMI.buttonHighlightedAlpha = UIControlHighlightedAlpha; // ButtonHighlightedAlpha : 按钮的highlighted alpha值
//- QMUICMI.buttonDisabledAlpha = UIControlDisabledAlpha; // ButtonDisabledAlpha : 按钮的disabled alpha值
//- QMUICMI.buttonTintColor = UIColorBlue; // ButtonTintColor : 按钮默认的tintColor
Expand All @@ -86,18 +86,18 @@ + (void)setupConfigurationTemplate {
//- QMUICMI.fillButtonColorWhite = UIColorWhite; // FillButtonColorWhite


#pragma mark - TextField & TextView
#pragma mark - TextField & TextView
//- QMUICMI.textFieldTintColor = UIColorBlue; // TextFieldTintColor : 全局UITextField、UITextView的tintColor
//- QMUICMI.textFieldTextInsets = UIEdgeInsetsMake(0, 7, 0, 7); // TextFieldTextInsets : QMUITextField的内边距

#pragma mark - ActionSheet
#pragma mark - ActionSheet
//- QMUICMI.actionSheetButtonTintColor = UIColorBlue; // ActionSheetButtonTintColor
//- QMUICMI.actionSheetButtonBackgroundColor = UIColorMake(255, 255, 255); // ActionSheetButtonBackgroundColor
//- QMUICMI.actionSheetButtonBackgroundColorHighlighted = UIColorMake(235, 235, 235); // ActionSheetButtonBackgroundColorHighlighted
//- QMUICMI.actionSheetButtonFont = UIFontMake(21); // ActionSheetButtonFont
//- QMUICMI.actionSheetButtonFontBold = UIFontBoldMake(21); // ActionSheetButtonFontBold

#pragma mark - NavigationBar
#pragma mark - NavigationBar

//- QMUICMI.navBarHighlightedAlpha = 0.2f; // NavBarHighlightedAlpha
//- QMUICMI.navBarDisabledAlpha = 0.2f; // NavBarDisabledAlpha
Expand All @@ -120,7 +120,7 @@ + (void)setupConfigurationTemplate {
//- QMUICMI.navBarActivityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; // NavBarActivityIndicatorViewStyle
//- QMUICMI.navBarAccessoryViewTypeDisclosureIndicatorImage = [UIImage imageWithShape:QMUIImageShapeTriangle size:CGSizeMake(8, 5) tintColor:UIColorWhite]; // NavBarAccessoryViewTypeDisclosureIndicatorImage

#pragma mark - TabBar
#pragma mark - TabBar

//- QMUICMI.tabBarBackgroundImage = nil; // TabBarBackgroundImage
//- QMUICMI.tabBarBarTintColor = nil; // TabBarBarTintColor
Expand All @@ -129,7 +129,7 @@ + (void)setupConfigurationTemplate {
//- QMUICMI.tabBarItemTitleColor = UIColorMake(119, 119, 119); // TabBarItemTitleColor
//- QMUICMI.tabBarItemTitleColorSelected = TabBarTintColor; // TabBarItemTitleColorSelected

#pragma mark - Toolbar
#pragma mark - Toolbar

//- QMUICMI.toolBarHighlightedAlpha = 0.4f; // ToolBarHighlightedAlpha
//- QMUICMI.toolBarDisabledAlpha = 0.4f; // ToolBarDisabledAlpha
Expand All @@ -141,7 +141,7 @@ + (void)setupConfigurationTemplate {
//- QMUICMI.toolBarShadowImageColor = UIColorMake(178, 178, 178); // ToolBarShadowImageColor
//- QMUICMI.toolBarButtonFont = UIFontMake(17); // ToolBarButtonFont

#pragma mark - SearchBar
#pragma mark - SearchBar

//- QMUICMI.searchBarTextFieldBackground = UIColorWhite; // SearchBarTextFieldBackground
//- QMUICMI.searchBarTextFieldBorderColor = UIColorMake(205, 208, 210); // SearchBarTextFieldBorderColor
Expand All @@ -154,7 +154,7 @@ + (void)setupConfigurationTemplate {
//- QMUICMI.searchBarClearIconImage = nil; // SearchBarClearIconImage
//- QMUICMI.searchBarTextFieldCornerRadius = 2.0; // SearchBarTextFieldCornerRadius

#pragma mark - TableView / TableViewCell
#pragma mark - TableView / TableViewCell

//- QMUICMI.tableViewBackgroundColor = UIColorWhite; // TableViewBackgroundColor
//- QMUICMI.tableViewGroupedBackgroundColor = UIColorForBackground; // TableViewGroupedBackgroundColor
Expand Down Expand Up @@ -194,13 +194,13 @@ + (void)setupConfigurationTemplate {
//- QMUICMI.tableViewCellContentDefaultPaddingLeft = 15; // TableViewCellContentDefaultPaddingLeft
//- QMUICMI.tableViewCellContentDefaultPaddingRight = 10; // TableViewCellContentDefaultPaddingRight

#pragma mark - UIWindowLevel
#pragma mark - UIWindowLevel
//- QMUICMI.windowLevelQMUIAlertView = UIWindowLevelAlert - 4.0; // UIWindowLevelQMUIAlertView
//- QMUICMI.windowLevelQMUIActionSheet = UIWindowLevelAlert - 4.0; // UIWindowLevelQMUIActionSheet
//- QMUICMI.windowLevelQMUIMoreOperationController = UIWindowLevelStatusBar + 1.0; // UIWindowLevelQMUIMoreOperationController
//- QMUICMI.windowLevelQMUIImagePreviewView = UIWindowLevelStatusBar + 1.0; // UIWindowLevelQMUIImagePreviewView

#pragma mark - Others
#pragma mark - Others

//- QMUICMI.supportedOrientationMask = UIInterfaceOrientationMaskPortrait; // SupportedOrientationMask : 默认支持的横竖屏方向
//- QMUICMI.statusbarStyleLightInitially = NO; // StatusbarStyleLightInitially : 默认的状态栏内容是否使用白色,默认为NO,也即黑色
Expand Down
Loading

0 comments on commit 81c482f

Please sign in to comment.