Skip to content

Commit

Permalink
Merge remote-tracking branch 'QMUI/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
wanhmr committed Mar 16, 2017
2 parents 7fe6992 + 173cb55 commit 14d6ca9
Show file tree
Hide file tree
Showing 73 changed files with 2,033 additions and 732 deletions.
4 changes: 2 additions & 2 deletions QMUIKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "QMUIKit"
s.version = "1.2"
s.version = "1.3.4"
s.summary = "致力于提高项目 UI 开发效率的解决方案"
s.description = <<-DESC
QMUI iOS 是一个致力于提高项目 UI 开发效率的解决方案,其设计目的是用于辅助快速搭建一个具备基本设计还原效果的 iOS 项目,同时利用自身提供的丰富控件及兼容处理, 让开发者能专注于业务需求而无需耗费精力在基础代码的设计上。不管是新项目的创建,或是已有项目的维护,均可使开发效率和项目质量得到大幅度提升。
Expand All @@ -20,6 +20,6 @@ Pod::Spec.new do |s|
# s.ios.exclude_files = 'Classes/osx'
# s.osx.exclude_files = 'Classes/ios'
# s.public_header_files = 'Classes/**/*.h'
s.frameworks = 'Foundation', 'UIKit', 'CoreGraphics'
s.frameworks = 'Foundation', 'UIKit', 'CoreGraphics', 'Photos'

end
4 changes: 4 additions & 0 deletions QMUIKit/QMUIKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ FOUNDATION_EXPORT const unsigned char QMUIKitVersionString[];
#import <QMUIKit/QMUICellHeightCache.h>
#import <QMUIKit/UITableView+QMUI.h>
#import <QMUIKit/UICollectionView+QMUI.h>
#import <QMUIKit/UITabBar+QMUI.h>
#import <QMUIKit/UITabBarItem+QMUI.h>
#import <QMUIKit/UIActivityIndicatorView+QMUI.h>
#import <QMUIKit/UIWindow+QMUI.h>
Expand Down Expand Up @@ -90,6 +91,7 @@ FOUNDATION_EXPORT const unsigned char QMUIKitVersionString[];
#import <QMUIKit/QMUIQQEmotionManager.h>
#import <QMUIKit/QMUIPieProgressView.h>
#import <QMUIKit/QMUIPopupContainerView.h>
#import <QMUIKit/QMUIPopupMenuView.h>
#import <QMUIKit/QMUIModalPresentationViewController.h>
#import <QMUIKit/QMUIAlertController.h>
#import <QMUIKit/QMUIAlbumViewController.h>
Expand Down Expand Up @@ -148,6 +150,7 @@ FOUNDATION_EXPORT const unsigned char QMUIKitVersionString[];
#import "QMUICellHeightCache.h"
#import "UITableView+QMUI.h"
#import "UICollectionView+QMUI.h"
#import "UITabBar+QMUI.h"
#import "UITabBarItem+QMUI.h"
#import "UIActivityIndicatorView+QMUI.h"
#import "UIWindow+QMUI.h"
Expand Down Expand Up @@ -178,6 +181,7 @@ FOUNDATION_EXPORT const unsigned char QMUIKitVersionString[];
#import "QMUIQQEmotionManager.h"
#import "QMUIPieProgressView.h"
#import "QMUIPopupContainerView.h"
#import "QMUIPopupMenuView.h"
#import "QMUIModalPresentationViewController.h"
#import "QMUIAlertController.h"
#import "QMUIAlbumViewController.h"
Expand Down
73 changes: 37 additions & 36 deletions QMUIKit/UICommon/QMUICommonDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,10 @@ EndIgnoreAvailabilityWarning

// 字体相关创建器,包括动态字体的支持
#define UIFontMake(size) [UIFont systemFontOfSize:size]
#define UIFontItalicMake(size) [UIFont italicSystemFontOfSize:size] // 斜体只对数字和字母有效,中文无效
#define UIFontBoldMake(size) [UIFont boldSystemFontOfSize:size]
#define UIFontBoldWithFont(_font) [UIFont boldSystemFontOfSize:_font.pointSize]
#define UIFontLightMake(size) [UIFont qmui_lightSystemFontOfSize:size] // 系统字体只对数字和字母有效,中文无效
#define UIFontLightMake(size) [UIFont qmui_lightSystemFontOfSize:size]
#define UIFontLightWithFont(_font) [UIFont qmui_lightSystemFontOfSize:_font.pointSize]
#define UIDynamicFontMake(size) [UIFont qmui_dynamicFontWithSize:size bold:NO]
#define UIDynamicFontMakeWithLimit(size, upperLimit, lowerLimit) [UIFont qmui_dynamicFontWithSize:size upperLimitSize:upperLimit lowerLimitSize:lowerLimit bold:NO]
Expand Down Expand Up @@ -214,39 +215,39 @@ EndIgnoreAvailabilityWarning
*
* 例如传进来 “2.1”,在 2x 倍数下会返回 2.5(0.5pt 对应 1px),在 3x 倍数下会返回 2.333(0.333pt 对应 1px)。
*/
CG_INLINE float
flatfSpecificScale(float floatValue, float scale) {
CG_INLINE CGFloat
flatSpecificScale(CGFloat floatValue, CGFloat scale) {
scale = scale == 0 ? ScreenScale : scale;
CGFloat flattedValue = ceilf(floatValue * scale) / scale;
CGFloat flattedValue = ceil(floatValue * scale) / scale;
return flattedValue;
}

/**
* 基于当前设备的屏幕倍数,对传进来的 floatValue 进行像素取整。
*
* 注意如果在 Core Graphic 绘图里使用时,要注意当前画布的倍数是否和设备屏幕倍数一致,若不一致,不可使用 flatf() 函数
* 注意如果在 Core Graphic 绘图里使用时,要注意当前画布的倍数是否和设备屏幕倍数一致,若不一致,不可使用 flat() 函数,而应该用 flatSpecificScale
*/
CG_INLINE float
flatf(float floatValue) {
return flatfSpecificScale(floatValue, 0);
CG_INLINE CGFloat
flat(CGFloat floatValue) {
return flatSpecificScale(floatValue, 0);
}

/**
* 类似flatf(),只不过 flatf 是向上取整,而 floorfInPixel 是向下取整
* 类似flat(),只不过 flat 是向上取整,而 floorInPixel 是向下取整
*/
CG_INLINE float
floorfInPixel(float floatValue) {
CGFloat resultValue = floorf(floatValue * ScreenScale) / ScreenScale;
CG_INLINE CGFloat
floorInPixel(CGFloat floatValue) {
CGFloat resultValue = floor(floatValue * ScreenScale) / ScreenScale;
return resultValue;
}

CG_INLINE BOOL
betweenf(float minimumValue, float value, float maximumValue) {
between(CGFloat minimumValue, CGFloat value, CGFloat maximumValue) {
return minimumValue < value && value < maximumValue;
}

CG_INLINE BOOL
betweenOrEqualf(float minimumValue, float value, float maximumValue) {
betweenOrEqual(CGFloat minimumValue, CGFloat value, CGFloat maximumValue) {
return minimumValue <= value && value <= maximumValue;
}

Expand All @@ -267,26 +268,26 @@ ReplaceMethod(Class _class, SEL _originSelector, SEL _newSelector) {
/// 用于居中运算
CG_INLINE CGFloat
CGFloatGetCenter(CGFloat parent, CGFloat child) {
return flatf((parent - child) / 2.0);
return flat((parent - child) / 2.0);
}

#pragma mark - CGPoint

/// 两个point相加
CG_INLINE CGPoint
CGPointUnion(CGPoint point1, CGPoint point2) {
return CGPointMake(flatf(point1.x + point2.x), flatf(point1.y + point2.y));
return CGPointMake(flat(point1.x + point2.x), flat(point1.y + point2.y));
}

/// 获取rect的center,包括rect本身的x/y偏移
CG_INLINE CGPoint
CGPointGetCenterWithRect(CGRect rect) {
return CGPointMake(flatf(CGRectGetMidX(rect)), flatf(CGRectGetMidY(rect)));
return CGPointMake(flat(CGRectGetMidX(rect)), flat(CGRectGetMidY(rect)));
}

CG_INLINE CGPoint
CGPointGetCenterWithSize(CGSize size) {
return CGPointMake(flatf(size.width / 2.0), flatf(size.height / 2.0));
return CGPointMake(flat(size.width / 2.0), flat(size.height / 2.0));
}

#pragma mark - UIEdgeInsets
Expand Down Expand Up @@ -315,24 +316,24 @@ UIEdgeInsetsConcat(UIEdgeInsets insets1, UIEdgeInsets insets2) {

CG_INLINE UIEdgeInsets
UIEdgeInsetsSetTop(UIEdgeInsets insets, CGFloat top) {
insets.top = flatf(top);
insets.top = flat(top);
return insets;
}

CG_INLINE UIEdgeInsets
UIEdgeInsetsSetLeft(UIEdgeInsets insets, CGFloat left) {
insets.left = flatf(left);
insets.left = flat(left);
return insets;
}
CG_INLINE UIEdgeInsets
UIEdgeInsetsSetBottom(UIEdgeInsets insets, CGFloat bottom) {
insets.bottom = flatf(bottom);
insets.bottom = flat(bottom);
return insets;
}

CG_INLINE UIEdgeInsets
UIEdgeInsetsSetRight(UIEdgeInsets insets, CGFloat right) {
insets.right = flatf(right);
insets.right = flat(right);
return insets;
}

Expand All @@ -347,19 +348,19 @@ CGSizeIsEmpty(CGSize size) {
/// 将一个CGSize像素对齐
CG_INLINE CGSize
CGSizeFlatted(CGSize size) {
return CGSizeMake(flatf(size.width), flatf(size.height));
return CGSizeMake(flat(size.width), flat(size.height));
}

/// 将一个 CGSize 以 pt 为单位向上取整
CG_INLINE CGSize
CGSizeCeil(CGSize size) {
return CGSizeMake(ceilf(size.width), ceilf(size.height));
return CGSizeMake(ceil(size.width), ceil(size.height));
}

/// 将一个 CGSize 以 pt 为单位向下取整
CG_INLINE CGSize
CGSizeFloor(CGSize size) {
return CGSizeMake(floorf(size.width), floorf(size.height));
return CGSizeMake(floor(size.width), floor(size.height));
}

#pragma mark - CGRect
Expand All @@ -373,13 +374,13 @@ CGRectIsNaN(CGRect rect) {
/// 创建一个像素对齐的CGRect
CG_INLINE CGRect
CGRectFlatMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height) {
return CGRectMake(flatf(x), flatf(y), flatf(width), flatf(height));
return CGRectMake(flat(x), flat(y), flat(width), flat(height));
}

/// 对CGRect的x/y、width/height都调用一次flatf,以保证像素对齐
/// 对CGRect的x/y、width/height都调用一次flat,以保证像素对齐
CG_INLINE CGRect
CGRectFlatted(CGRect rect) {
return CGRectMake(flatf(rect.origin.x), flatf(rect.origin.y), flatf(rect.size.width), flatf(rect.size.height));
return CGRectMake(flat(rect.origin.x), flat(rect.origin.y), flat(rect.size.width), flat(rect.size.height));
}

/// 为一个CGRect叠加scale计算
Expand All @@ -391,13 +392,13 @@ CGRectApplyScale(CGRect rect, CGFloat scale) {
/// 计算view的水平居中,传入父view和子view的frame,返回子view在水平居中时的x值
CG_INLINE CGFloat
CGRectGetMinXHorizontallyCenterInParentRect(CGRect parentRect, CGRect childRect) {
return flatf((CGRectGetWidth(parentRect) - CGRectGetWidth(childRect)) / 2.0);
return flat((CGRectGetWidth(parentRect) - CGRectGetWidth(childRect)) / 2.0);
}

/// 计算view的垂直居中,传入父view和子view的frame,返回子view在垂直居中时的y值
CG_INLINE CGFloat
CGRectGetMinYVerticallyCenterInParentRect(CGRect parentRect, CGRect childRect) {
return flatf((CGRectGetHeight(parentRect) - CGRectGetHeight(childRect)) / 2.0);
return flat((CGRectGetHeight(parentRect) - CGRectGetHeight(childRect)) / 2.0);
}

/// 返回值:同一个坐标系内,想要layoutingRect和已布局完成的referenceRect保持垂直居中时,layoutingRect的originY
Expand Down Expand Up @@ -480,32 +481,32 @@ CGRectLimitMaxWidth(CGRect rect, CGFloat maxWidth) {

CG_INLINE CGRect
CGRectSetX(CGRect rect, CGFloat x) {
rect.origin.x = flatf(x);
rect.origin.x = flat(x);
return rect;
}

CG_INLINE CGRect
CGRectSetY(CGRect rect, CGFloat y) {
rect.origin.y = flatf(y);
rect.origin.y = flat(y);
return rect;
}

CG_INLINE CGRect
CGRectSetXY(CGRect rect, CGFloat x, CGFloat y) {
rect.origin.x = flatf(x);
rect.origin.y = flatf(y);
rect.origin.x = flat(x);
rect.origin.y = flat(y);
return rect;
}

CG_INLINE CGRect
CGRectSetWidth(CGRect rect, CGFloat width) {
rect.size.width = flatf(width);
rect.size.width = flat(width);
return rect;
}

CG_INLINE CGRect
CGRectSetHeight(CGRect rect, CGFloat height) {
rect.size.height = flatf(height);
rect.size.height = flat(height);
return rect;
}

Expand Down
2 changes: 0 additions & 2 deletions QMUIKit/UICommon/QMUIConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@
#define NavBarShadowImage [QMUICMI navBarShadowImage]
#define NavBarBarTintColor [QMUICMI navBarBarTintColor]
#define NavBarTintColor [QMUICMI navBarTintColor]
#define NavBarTintColorHighlighted [QMUICMI navBarTintColorHighlighted]
#define NavBarTintColorDisabled [QMUICMI navBarTintColorDisabled]
#define NavBarTitleColor [QMUICMI navBarTitleColor]
#define NavBarTitleFont [QMUICMI navBarTitleFont]
#define NavBarBarBackButtonTitlePositionAdjustment [QMUICMI navBarBackButtonTitlePositionAdjustment]
Expand Down
16 changes: 7 additions & 9 deletions QMUIKit/UICommon/QMUIConfigurationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@
@property(nonatomic, strong) UIColor *navBarShadowImageColor;
@property(nonatomic, strong) UIColor *navBarBarTintColor;
@property(nonatomic, strong) UIColor *navBarTintColor;
@property(nonatomic, strong) UIColor *navBarTintColorHighlighted;
@property(nonatomic, strong) UIColor *navBarTintColorDisabled;
@property(nonatomic, strong) UIColor *navBarTitleColor;
@property(nonatomic, strong) UIFont *navBarTitleFont;
@property(nonatomic, assign) UIOffset navBarBackButtonTitlePositionAdjustment;
Expand Down Expand Up @@ -154,13 +152,18 @@
@property(nonatomic, strong) UIColor *tableSectionIndexBackgroundColor;
@property(nonatomic, strong) UIColor *tableSectionIndexTrackingBackgroundColor;
@property(nonatomic, strong) UIColor *tableViewSeparatorColor;

@property(nonatomic, assign) CGFloat tableViewCellNormalHeight;
@property(nonatomic, strong) UIColor *tableViewCellTitleLabelColor;
@property(nonatomic, strong) UIColor *tableViewCellDetailLabelColor;
@property(nonatomic, assign) CGFloat tableViewCellContentDefaultPaddingLeft;
@property(nonatomic, assign) CGFloat tableViewCellContentDefaultPaddingRight;
@property(nonatomic, strong) UIColor *tableViewCellBackgroundColor;
@property(nonatomic, strong) UIColor *tableViewCellSelectedBackgroundColor;
@property(nonatomic, strong) UIColor *tableViewCellWarningBackgroundColor;
@property(nonatomic, assign) CGFloat tableViewCellNormalHeight;

@property(nonatomic, strong) UIImage *tableViewCellDisclosureIndicatorImage;
@property(nonatomic, strong) UIImage *tableViewCellCheckmarkImage;

@property(nonatomic, strong) UIColor *tableViewSectionHeaderBackgroundColor;
@property(nonatomic, strong) UIColor *tableViewSectionFooterBackgroundColor;
@property(nonatomic, strong) UIFont *tableViewSectionHeaderFont;
Expand All @@ -181,11 +184,6 @@
@property(nonatomic, assign) UIEdgeInsets tableViewGroupedSectionHeaderContentInset;
@property(nonatomic, assign) UIEdgeInsets tableViewGroupedSectionFooterContentInset;

@property(nonatomic, strong) UIColor *tableViewCellTitleLabelColor;
@property(nonatomic, strong) UIColor *tableViewCellDetailLabelColor;
@property(nonatomic, assign) CGFloat tableViewCellContentDefaultPaddingLeft;
@property(nonatomic, assign) CGFloat tableViewCellContentDefaultPaddingRight;

#pragma mark - Others

@property(nonatomic, assign) UIInterfaceOrientationMask supportedOrientationMask;
Expand Down
15 changes: 7 additions & 8 deletions QMUIKit/UICommon/QMUIConfigurationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ - (void)initDefaultConfiguration {
self.navBarShadowImageColor = UIColorMake(178, 178, 178);
self.navBarBarTintColor = nil;
self.navBarTintColor = self.blackColor;
self.navBarTintColorHighlighted = [self.navBarTintColor colorWithAlphaComponent:self.navBarHighlightedAlpha];
self.navBarTintColorDisabled = [self.navBarTintColor colorWithAlphaComponent:self.navBarDisabledAlpha];
self.navBarTitleColor = nil;
self.navBarTitleFont = UIFontBoldMake(17);
self.navBarBackButtonTitlePositionAdjustment = UIOffsetZero;
Expand Down Expand Up @@ -225,25 +223,26 @@ + (void)renderGlobalAppearances {

// UINavigationBar
UINavigationBar *navigationBarAppearance = [UINavigationBar appearance];
[navigationBarAppearance setBarTintColor:NavBarBarTintColor];
navigationBarAppearance.barTintColor = NavBarBarTintColor;
navigationBarAppearance.shadowImage = NavBarShadowImage;
navigationBarAppearance.titleTextAttributes = @{NSFontAttributeName: NavBarTitleFont, NSForegroundColorAttributeName: NavBarTitleColor};
[navigationBarAppearance setBackgroundImage:NavBarBackgroundImage forBarMetrics:UIBarMetricsDefault];
[navigationBarAppearance setShadowImage:NavBarShadowImage];

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

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


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

0 comments on commit 14d6ca9

Please sign in to comment.