Skip to content

Commit

Permalink
4.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MoLice committed Oct 10, 2019
1 parent 2475144 commit 3fa84db
Show file tree
Hide file tree
Showing 64 changed files with 577 additions and 174 deletions.
5 changes: 3 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 = "4.0.0"
s.version = "4.0.1"
s.summary = "致力于提高项目 UI 开发效率的解决方案"
s.description = <<-DESC
QMUI iOS 是一个致力于提高项目 UI 开发效率的解决方案,其设计目的是用于辅助快速搭建一个具备基本设计还原效果的 iOS 项目,同时利用自身提供的丰富控件及兼容处理, 让开发者能专注于业务需求而无需耗费精力在基础代码的设计上。不管是新项目的创建,或是已有项目的维护,均可使开发效率和项目质量得到大幅度提升。
Expand All @@ -27,7 +27,7 @@ Pod::Spec.new do |s|
end

s.subspec 'QMUIResources' do |ss|
ss.resource = 'QMUIKit/QMUIResources/*.bundle'
ss.resource = 'QMUIKit/QMUIResources/*.*'
end

s.subspec 'QMUIMainFrame' do |ss|
Expand Down Expand Up @@ -304,6 +304,7 @@ Pod::Spec.new do |s|
sss.dependency 'QMUIKit/QMUIComponents/QMUITextView'
sss.dependency 'QMUIKit/QMUIComponents/QMUIVisualEffectView'
sss.dependency 'QMUIKit/QMUIComponents/QMUIToastView'
sss.dependency 'QMUIKit/QMUIComponents/QMUIModalPresentationViewController'
end

ss.subspec 'QMUITips' do |sss|
Expand Down
11 changes: 10 additions & 1 deletion QMUIKit/QMUIComponents/QMUIButton/QMUINavigationButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,16 @@ + (void)load {
if (navigationBar.items.count == 2 && !navigationBar.backItem.leftBarButtonItem && item.leftBarButtonItem.qmui_isCustomizedBackBarButtonItem) {
// 如果从自定义返回按钮界面返回到根界面,且根界面左上角没有按钮,则不调整 layout,不然会有跳动。理论上不应该这么改,但暂时没想到优雅的解决方式
} else {
navigationBar.qmui_customizingBackBarButtonItem = navigationBar.backItem.leftBarButtonItem.qmui_isCustomizedBackBarButtonItem;
// https://github.com/Tencent/QMUI_iOS/issues/737 这里要考虑自定义返回按钮的情况,leftBarButtonItem 和 backBarButtonItem 同时存在的情况下,leftBarButtonItem 会优先显示
if (navigationBar.topItem.leftBarButtonItem) {
// topViewController.navigationItem.leftBarButtonItem
navigationBar.qmui_customizingBackBarButtonItem = navigationBar.topItem.leftBarButtonItem.qmui_isCustomizedBackBarButtonItem;
} else if (navigationBar.backItem.leftBarButtonItem) {
// topViewController.navigationItem.backBarButtonItem
navigationBar.qmui_customizingBackBarButtonItem = navigationBar.backItem.leftBarButtonItem.qmui_isCustomizedBackBarButtonItem;
} else {
navigationBar.qmui_customizingBackBarButtonItem = NO;
}
}
}
}
Expand Down
15 changes: 13 additions & 2 deletions QMUIKit/QMUIComponents/QMUIConsole/QMUIConsole.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,19 @@ + (void)clear {
+ (void)show {
QMUIConsole *console = [QMUIConsole sharedInstance];
if (console.canShow) {
[[QMUIConsole sharedInstance] initConsoleWindowIfNeeded];
[QMUIConsole sharedInstance].consoleWindow.hidden = NO;

if (!console.consoleWindow.hidden) return;

// 在某些情况下 show 的时候刚好界面正在做动画,就可能会看到 consoleWindow 从左上角展开的过程(window 默认背景色是黑色的),所以这里做了一些小处理
// https://github.com/Tencent/QMUI_iOS/issues/743
[UIView performWithoutAnimation:^{
[console initConsoleWindowIfNeeded];
console.consoleWindow.alpha = 0;
console.consoleWindow.hidden = NO;
}];
[UIView animateWithDuration:.25 delay:.2 options:QMUIViewAnimationOptionsCurveOut animations:^{
console.consoleWindow.alpha = 1;
} completion:nil];
}
}

Expand Down
1 change: 0 additions & 1 deletion QMUIKit/QMUIComponents/QMUIDialogViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ - (void)removeSubmitButton {
- (QMUIButton *)generateButtonWithText:(NSString *)buttonText {
QMUIButton *button = [[QMUIButton alloc] init];
button.titleLabel.font = UIFontBoldMake((IS_320WIDTH_SCREEN) ? 14 : 15);
button.adjustsTitleTintColorAutomatically = YES;
button.backgroundColor = self.buttonBackgroundColor;
button.highlightedBackgroundColor = self.buttonHighlightedBackgroundColor;
[button setAttributedTitle:[[NSAttributedString alloc] initWithString:buttonText attributes:self.buttonTitleAttributes] forState:UIControlStateNormal];
Expand Down
15 changes: 11 additions & 4 deletions QMUIKit/QMUIComponents/QMUIPopupMenuView/QMUIPopupMenuButtonItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,17 @@ - (void)setTitle:(NSString *)title {
- (void)setImage:(UIImage *)image {
_image = image;
[self.button setImage:image forState:UIControlStateNormal];
if (image) {
self.button.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, self.imageMarginRight);
} else {
self.button.imageEdgeInsets = UIEdgeInsetsZero;
[self updateButtonImageEdgeInsets];
}

- (void)setImageMarginRight:(CGFloat)imageMarginRight {
_imageMarginRight = imageMarginRight;
[self updateButtonImageEdgeInsets];
}

- (void)updateButtonImageEdgeInsets {
if (self.button.currentImage) {
self.button.imageEdgeInsets = UIEdgeInsetsSetRight(self.button.imageEdgeInsets, self.imageMarginRight);
}
}

Expand Down
15 changes: 15 additions & 0 deletions QMUIKit/QMUIComponents/QMUITheme/UIViewController+QMUITheme.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,28 @@
//

#import "UIViewController+QMUITheme.h"
#import "QMUIModalPresentationViewController.h"

@implementation UIViewController (QMUITheme)

- (void)qmui_themeDidChangeByManager:(QMUIThemeManager *)manager identifier:(__kindof NSObject<NSCopying> *)identifier theme:(__kindof NSObject *)theme {
[self.childViewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull childViewController, NSUInteger idx, BOOL * _Nonnull stop) {
[childViewController qmui_themeDidChangeByManager:manager identifier:identifier theme:theme];
}];
if (self.presentedViewController && self.presentedViewController.presentingViewController == self) {
[self.presentedViewController qmui_themeDidChangeByManager:manager identifier:identifier theme:theme];
}
}

@end

@implementation QMUIModalPresentationViewController (QMUITheme)

- (void)qmui_themeDidChangeByManager:(QMUIThemeManager *)manager identifier:(__kindof NSObject<NSCopying> *)identifier theme:(__kindof NSObject *)theme {
[super qmui_themeDidChangeByManager:manager identifier:identifier theme:theme];
if (self.contentViewController) {
[self.contentViewController qmui_themeDidChangeByManager:manager identifier:identifier theme:theme];
}
}

@end
47 changes: 30 additions & 17 deletions QMUIKit/QMUICore/QMUIConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ - (void)setTabBarStyle:(UIBarStyle)tabBarStyle {

- (void)setTabBarBackgroundImage:(UIImage *)tabBarBackgroundImage {
_tabBarBackgroundImage = tabBarBackgroundImage;

#ifdef IOS13_SDK_ALLOWED
if (@available(iOS 13.0, *)) {
self.tabBarAppearance.backgroundImage = tabBarBackgroundImage;
Expand All @@ -572,6 +573,7 @@ - (void)setTabBarBackgroundImage:(UIImage *)tabBarBackgroundImage {

- (void)setTabBarShadowImageColor:(UIColor *)tabBarShadowImageColor {
_tabBarShadowImageColor = tabBarShadowImageColor;

#ifdef IOS13_SDK_ALLOWED
if (@available(iOS 13.0, *)) {
self.tabBarAppearance.shadowColor = tabBarShadowImageColor;
Expand All @@ -590,11 +592,14 @@ - (void)setTabBarShadowImageColor:(UIColor *)tabBarShadowImageColor {

- (void)setTabBarItemTitleFont:(UIFont *)tabBarItemTitleFont {
_tabBarItemTitleFont = tabBarItemTitleFont;

#ifdef IOS13_SDK_ALLOWED
if (@available(iOS 13.0, *)) {
NSMutableDictionary<NSAttributedStringKey, id> *attributes = self.tabBarAppearance.stackedLayoutAppearance.normal.titleTextAttributes.mutableCopy;
attributes[NSFontAttributeName] = tabBarItemTitleFont;
self.tabBarAppearance.stackedLayoutAppearance.normal.titleTextAttributes = attributes.copy;
[self.tabBarAppearance qmui_applyItemAppearanceWithBlock:^(UITabBarItemAppearance * _Nonnull itemAppearance) {
NSMutableDictionary<NSAttributedStringKey, id> *attributes = itemAppearance.normal.titleTextAttributes.mutableCopy;
attributes[NSFontAttributeName] = tabBarItemTitleFont;
itemAppearance.normal.titleTextAttributes = attributes.copy;
}];
[self updateTabBarAppearance];
} else {
#endif
Expand All @@ -615,18 +620,19 @@ - (void)setTabBarItemTitleFont:(UIFont *)tabBarItemTitleFont {

- (void)setTabBarItemTitleColor:(UIColor *)tabBarItemTitleColor {
_tabBarItemTitleColor = tabBarItemTitleColor;

#ifdef IOS13_SDK_ALLOWED
if (@available(iOS 13.0, *)) {
NSMutableDictionary<NSAttributedStringKey, id> *attributes = self.tabBarAppearance.stackedLayoutAppearance.normal.titleTextAttributes.mutableCopy;
attributes[NSForegroundColorAttributeName] = tabBarItemTitleColor;
self.tabBarAppearance.stackedLayoutAppearance.normal.titleTextAttributes = attributes.copy;
[self.tabBarAppearance qmui_applyItemAppearanceWithBlock:^(UITabBarItemAppearance * _Nonnull itemAppearance) {
NSMutableDictionary<NSAttributedStringKey, id> *attributes = itemAppearance.normal.titleTextAttributes.mutableCopy;
attributes[NSForegroundColorAttributeName] = tabBarItemTitleColor;
itemAppearance.normal.titleTextAttributes = attributes.copy;
}];
[self updateTabBarAppearance];
} else {
#endif
NSMutableDictionary<NSString *, id> *textAttributes = [[NSMutableDictionary alloc] initWithDictionary:[[UITabBarItem appearance] titleTextAttributesForState:UIControlStateNormal]];
if (_tabBarItemTitleColor) {
textAttributes[NSForegroundColorAttributeName] = _tabBarItemTitleColor;
}
textAttributes[NSForegroundColorAttributeName] = _tabBarItemTitleColor;
[[UITabBarItem appearance] setTitleTextAttributes:textAttributes forState:UIControlStateNormal];
[self.appearanceUpdatingTabBarControllers enumerateObjectsUsingBlock:^(UITabBarController * _Nonnull tabBarController, NSUInteger idx, BOOL * _Nonnull stop) {
[tabBarController.tabBar.items enumerateObjectsUsingBlock:^(UITabBarItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
Expand All @@ -640,18 +646,19 @@ - (void)setTabBarItemTitleColor:(UIColor *)tabBarItemTitleColor {

- (void)setTabBarItemTitleColorSelected:(UIColor *)tabBarItemTitleColorSelected {
_tabBarItemTitleColorSelected = tabBarItemTitleColorSelected;

#ifdef IOS13_SDK_ALLOWED
if (@available(iOS 13.0, *)) {
NSMutableDictionary<NSAttributedStringKey, id> *attributes = self.tabBarAppearance.stackedLayoutAppearance.selected.titleTextAttributes.mutableCopy;
attributes[NSForegroundColorAttributeName] = tabBarItemTitleColorSelected;
self.tabBarAppearance.stackedLayoutAppearance.selected.titleTextAttributes = attributes.copy;
[self.tabBarAppearance qmui_applyItemAppearanceWithBlock:^(UITabBarItemAppearance * _Nonnull itemAppearance) {
NSMutableDictionary<NSAttributedStringKey, id> *attributes = itemAppearance.selected.titleTextAttributes.mutableCopy;
attributes[NSForegroundColorAttributeName] = tabBarItemTitleColorSelected;
itemAppearance.selected.titleTextAttributes = attributes.copy;
}];
[self updateTabBarAppearance];
} else {
#endif
NSMutableDictionary<NSString *, id> *textAttributes = [[NSMutableDictionary alloc] initWithDictionary:[[UITabBarItem appearance] titleTextAttributesForState:UIControlStateSelected]];
if (_tabBarItemTitleColorSelected) {
textAttributes[NSForegroundColorAttributeName] = _tabBarItemTitleColorSelected;
}
textAttributes[NSForegroundColorAttributeName] = _tabBarItemTitleColorSelected;
[[UITabBarItem appearance] setTitleTextAttributes:textAttributes forState:UIControlStateSelected];
[self.appearanceUpdatingTabBarControllers enumerateObjectsUsingBlock:^(UITabBarController * _Nonnull tabBarController, NSUInteger idx, BOOL * _Nonnull stop) {
[tabBarController.tabBar.items enumerateObjectsUsingBlock:^(UITabBarItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
Expand All @@ -665,9 +672,12 @@ - (void)setTabBarItemTitleColorSelected:(UIColor *)tabBarItemTitleColorSelected

- (void)setTabBarItemImageColor:(UIColor *)tabBarItemImageColor {
_tabBarItemImageColor = tabBarItemImageColor;

#ifdef IOS13_SDK_ALLOWED
if (@available(iOS 13.0, *)) {
self.tabBarAppearance.stackedLayoutAppearance.normal.iconColor = tabBarItemImageColor;
[self.tabBarAppearance qmui_applyItemAppearanceWithBlock:^(UITabBarItemAppearance * _Nonnull itemAppearance) {
itemAppearance.normal.iconColor = tabBarItemImageColor;
}];
[self updateTabBarAppearance];
} else {
#endif
Expand All @@ -685,9 +695,12 @@ - (void)setTabBarItemImageColor:(UIColor *)tabBarItemImageColor {

- (void)setTabBarItemImageColorSelected:(UIColor *)tabBarItemImageColorSelected {
_tabBarItemImageColorSelected = tabBarItemImageColorSelected;

#ifdef IOS13_SDK_ALLOWED
if (@available(iOS 13.0, *)) {
self.tabBarAppearance.stackedLayoutAppearance.selected.iconColor = tabBarItemImageColorSelected;
[self.tabBarAppearance qmui_applyItemAppearanceWithBlock:^(UITabBarItemAppearance * _Nonnull itemAppearance) {
itemAppearance.selected.iconColor = tabBarItemImageColorSelected;
}];
[self updateTabBarAppearance];
} else {
#endif
Expand Down
21 changes: 10 additions & 11 deletions QMUIKit/QMUICore/QMUIHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,19 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface QMUIHelper : NSObject

+ (instancetype _Nonnull)sharedInstance;
+ (instancetype)sharedInstance;
@end


extern NSString *const _Nonnull QMUIResourcesMainBundleName;

@interface QMUIHelper (Bundle)

// QMUI专属
+ (nullable NSBundle *)resourcesBundle;
+ (nullable UIImage *)imageWithName:(nullable NSString *)name;
/// 获取 QMUIKit.framework Images.xcassets 内的图片资源
/// @param name 图片名
+ (nullable UIImage *)imageWithName:(NSString *)name;

+ (nullable NSBundle *)resourcesBundleWithName:(nullable NSString *)bundleName;
+ (nullable UIImage *)imageInBundle:(nullable NSBundle *)bundle withName:(nullable NSString *)name;
@end

@interface QMUIHelper (SystemVersion)
Expand Down Expand Up @@ -124,8 +121,8 @@ extern NSString *const _Nonnull QMUIResourcesMainBundleName;
+ (void)inspectContextSize:(CGSize)size;

/// context是否合法
+ (void)inspectContextIfInvalidatedInDebugMode:(CGContextRef _Nonnull)context;
+ (BOOL)inspectContextIfInvalidatedInReleaseMode:(CGContextRef _Nonnull)context;
+ (void)inspectContextIfInvalidatedInDebugMode:(CGContextRef)context;
+ (BOOL)inspectContextIfInvalidatedInReleaseMode:(CGContextRef)context;
@end


Expand Down Expand Up @@ -228,3 +225,5 @@ extern NSString *const _Nonnull QMUIResourcesMainBundleName;
+ (void)executeAnimationBlock:(nonnull __attribute__((noescape)) void (^)(void))animationBlock completionBlock:(nullable __attribute__((noescape)) void (^)(void))completionBlock;

@end

NS_ASSUME_NONNULL_END
43 changes: 2 additions & 41 deletions QMUIKit/QMUICore/QMUIHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,50 +24,11 @@
#import <math.h>
#import <sys/utsname.h>

NSString *const QMUIResourcesMainBundleName = @"QMUIResources.bundle";

@implementation QMUIHelper (Bundle)

+ (NSBundle *)resourcesBundle {
return [QMUIHelper resourcesBundleWithName:QMUIResourcesMainBundleName];
}

+ (NSBundle *)resourcesBundleWithName:(NSString *)bundleName {
NSBundle *bundle = [NSBundle bundleWithPath: [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:bundleName]];
if (!bundle) {
// 动态framework的bundle资源是打包在framework里面的,所以无法通过mainBundle拿到资源,只能通过其他方法来获取bundle资源。
NSBundle *frameworkBundle = [NSBundle bundleForClass:[self class]];
NSDictionary *bundleData = [self parseBundleName:bundleName];
if (bundleData) {
bundle = [NSBundle bundleWithPath:[frameworkBundle pathForResource:[bundleData objectForKey:@"name"] ofType:[bundleData objectForKey:@"type"]]];
}
}
return bundle;
}

+ (UIImage *)imageWithName:(NSString *)name {
NSBundle *bundle = [QMUIHelper resourcesBundle];
return [QMUIHelper imageInBundle:bundle withName:name];
}

+ (UIImage *)imageInBundle:(NSBundle *)bundle withName:(NSString *)name {
if (bundle && name) {
if ([UIImage respondsToSelector:@selector(imageNamed:inBundle:compatibleWithTraitCollection:)]) {
return [UIImage imageNamed:name inBundle:bundle compatibleWithTraitCollection:nil];
} else {
NSString *imagePath = [[bundle resourcePath] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png", name]];
return [UIImage imageWithContentsOfFile:imagePath];
}
}
return nil;
}

+ (NSDictionary *)parseBundleName:(NSString *)bundleName {
NSArray *bundleData = [bundleName componentsSeparatedByString:@"."];
if (bundleData.count == 2) {
return @{@"name":bundleData[0], @"type":bundleData[1]};
}
return nil;
NSBundle *bundle = [NSBundle bundleForClass:self.class];
return [UIImage imageNamed:name inBundle:bundle compatibleWithTraitCollection:nil];
}

@end
Expand Down
6 changes: 6 additions & 0 deletions QMUIKit/QMUIResources/Images.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
File renamed without changes
File renamed without changes
Loading

0 comments on commit 3fa84db

Please sign in to comment.