Skip to content

Commit

Permalink
4.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MoLice committed Mar 30, 2020
1 parent 9e366c0 commit 413483a
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 57 deletions.
2 changes: 1 addition & 1 deletion QMUIConfigurationTemplate/QMUIConfigurationTemplate.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ - (void)applyConfigurationTemplate {
QMUICMI.navBarButtonFontBold = nil; // NavBarButtonFontBold : QMUINavigationButtonTypeBold 的字体
QMUICMI.navBarBackgroundImage = nil; // NavBarBackgroundImage : UINavigationBar 的背景图
QMUICMI.navBarShadowImage = nil; // NavBarShadowImage : UINavigationBar.shadowImage,也即导航栏底部那条分隔线,配合 NavBarShadowImageColor 使用。
QMUICMI.navBarShadowImageColor = nil; // NavBarShadowImageColor : UINavigationBar.shadowImage 的颜色,如果为 nil,则显示系统默认 shadowImage,如果为全透明,则不显示 shadowImage,如果为除了 nil 和全透明外的其他颜色,则会将这个颜色叠加到 NavBarShadowImage 上显示出来,如果不存在 NavBarShadowImage,则使用一张 1px 高的图片作为默认图
QMUICMI.navBarShadowImageColor = nil; // NavBarShadowImageColor : UINavigationBar.shadowImage 的颜色,如果为 nil,则使用 NavBarShadowImage 的值,如果 NavBarShadowImage 也为 nil,则使用系统默认的分隔线。如果不为 nil,而 NavBarShadowImage 为 nil,则自动创建一张 1px 高的图并将其设置为 NavBarShadowImageColor 的颜色然后设置上去,如果 NavBarShadowImage 不为 nil 且 renderingMode 不为 UIImageRenderingModeAlwaysOriginal,则将 NavBarShadowImage 设置为 NavBarShadowImageColor 的颜色然后设置上去
QMUICMI.navBarBarTintColor = nil; // NavBarBarTintColor : UINavigationBar.barTintColor,也即背景色
QMUICMI.navBarStyle = UIBarStyleDefault; // NavBarStyle : UINavigationBar 的 barStyle
QMUICMI.navBarTintColor = nil; // NavBarTintColor : QMUINavigationController.navigationBar 的 tintColor,也即导航栏上面的按钮颜色,由于 tintColor 不支持 appearance,所以这里只支持 QMUINavigationController
Expand Down
2 changes: 1 addition & 1 deletion 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.1.0"
s.version = "4.1.1"
s.summary = "致力于提高项目 UI 开发效率的解决方案"
s.description = <<-DESC
QMUI iOS 是一个致力于提高项目 UI 开发效率的解决方案,其设计目的是用于辅助快速搭建一个具备基本设计还原效果的 iOS 项目,同时利用自身提供的丰富控件及兼容处理, 让开发者能专注于业务需求而无需耗费精力在基础代码的设计上。不管是新项目的创建,或是已有项目的维护,均可使开发效率和项目质量得到大幅度提升。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ @implementation QMUIAlbumViewController
- (void)didInitialize {
[super didInitialize];
_shouldShowDefaultLoadingView = YES;
self.albumTableViewCellHeight = [QMUIAlbumViewController appearance].albumTableViewCellHeight;
[self qmui_applyAppearance];
}

- (void)setupNavigationItems {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#import "QMUIButton.h"
#import "UIView+QMUI.h"
#import "NSString+QMUI.h"
#import "QMUIAppearance.h"

@interface QMUIImagePickerCollectionViewCell ()

Expand Down Expand Up @@ -55,14 +56,7 @@ - (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initImagePickerCollectionViewCellUI];
self.favoriteImage = [QMUIImagePickerCollectionViewCell appearance].favoriteImage;
self.favoriteImageMargins = [QMUIImagePickerCollectionViewCell appearance].favoriteImageMargins;
self.checkboxImage = [QMUIImagePickerCollectionViewCell appearance].checkboxImage;
self.checkboxCheckedImage = [QMUIImagePickerCollectionViewCell appearance].checkboxCheckedImage;
self.checkboxButtonMargins = [QMUIImagePickerCollectionViewCell appearance].checkboxButtonMargins;
self.videoDurationLabelFont = [QMUIImagePickerCollectionViewCell appearance].videoDurationLabelFont;
self.videoDurationLabelTextColor = [QMUIImagePickerCollectionViewCell appearance].videoDurationLabelTextColor;
self.videoDurationLabelMargins = [QMUIImagePickerCollectionViewCell appearance].videoDurationLabelMargins;
[self qmui_applyAppearance];
}
return self;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,9 @@ - (void)renderNavigationStyleInViewController:(UIViewController *)viewController

// 导航栏底部的分隔线
if ([vc respondsToSelector:@selector(navigationBarShadowImage)]) {
UIImage *shadowImage = [vc navigationBarShadowImage];
[viewController.navigationController.navigationBar setShadowImage:shadowImage];
viewController.navigationController.navigationBar.shadowImage = [vc navigationBarShadowImage];
} else if (QMUICMIActivated) {
// 分隔线的实际控制权在 NavBarShadowImageColor 上,但这里又不适合重新使用 NavBarShadowImageColor 再生成一遍 image,而配置表的值最终都是设置到 appearance 上,所以这里用 appearance 来获取值,而不是直接读取 NavBarShadowImage
[viewController.navigationController.navigationBar setShadowImage:UINavigationBar.appearance.shadowImage];
viewController.navigationController.navigationBar.shadowImage = NavBarShadowImage;
}

// 导航栏上控件的主题色
Expand Down
4 changes: 2 additions & 2 deletions QMUIKit/QMUIComponents/QMUIAppearance.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ UIKit 仅提供了对 UIView 默认的 UIAppearance 支持,如果你是一个
4. 在恰当的时机为目标类的 appearance 赋初始值,QMUI 通常在类的 +initialize 方法里赋值。
5. 在类初始化实例的时候(例如 init 方法里)调用 -qmui_applyQMUIAppearance 为实例赋初始值。
5. 在类初始化实例的时候(例如 init 方法里)调用 -qmui_applyQMUIAppearance 为实例赋初始值,注意如果你的父类已经调用过的话,子类不需要再重复调用
@note 特别的,如果你正在为一个 UIView 子类支持 UIAppearance,不需要用到 QMUIAppearance,直接将属性、方法加上 UI_APPEARANCE_SELECTOR 标记即可,也不需要通过 -qmui_applyAppearance 的方式赋初始值,系统都已经帮你处理好了,具体可查看 UIKit Documentation。
@note 特别的,如果你正在为一个 UIView 子类支持 UIAppearance,不需要用到 QMUIAppearance,直接将属性、方法加上 UI_APPEARANCE_SELECTOR 标记即可,也不需要通过 -qmui_applyAppearance 的方式赋初始值(除非你希望这个赋值时机提前,系统默认时机是在 didMoveToWindow 时),系统都已经帮你处理好了,具体可查看 UIKit Documentation。
*/
@interface QMUIAppearance : NSObject

Expand Down
15 changes: 10 additions & 5 deletions QMUIKit/QMUIComponents/QMUIAppearance.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,18 @@ + (instancetype)appearance;

@implementation NSObject (QMUIAppearnace)

/**
关于 appearance 要考虑这几点:
1. 是否产生内存泄漏
2. 父类的 appearance 能否在子类里生效
3. 如果某个 property 在 ClassA 里声明为 UI_APPEARANCE_SELECTOR,则在子类 Class B : Class A 里获取该 property 的值将为 nil,这是正常的,系统默认行为如此,系统是在 应用 appearance 的时候发现子类的 property 值为 nil 时才会从父类里读取值,在这个阶段才完成继承效果。
*/
- (void)qmui_applyAppearance {
if ([self.class respondsToSelector:@selector(appearance)]) {
NSArray<NSInvocation *> *invocations = [self.class.appearance valueForKey:@"_appearanceInvocations"];
[invocations enumerateObjectsUsingBlock:^(NSInvocation * _Nonnull invocation, NSUInteger idx, BOOL * _Nonnull stop) {
invocation.target = [QMUIWeakObjectContainer containerWithObject:self];
[invocation invoke];
}];
BeginIgnorePerformSelectorLeaksWarning
SEL selector = NSSelectorFromString([NSString stringWithFormat:@"_%@:%@:", @"applyInvocationsTo", @"window"]);
[NSClassFromString(@"_UIAppearance") performSelector:selector withObject:self withObject:nil];
EndIgnorePerformSelectorLeaksWarning
}
}

Expand Down
26 changes: 2 additions & 24 deletions QMUIKit/QMUIComponents/QMUIDialogViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,8 @@ @implementation QMUIDialogViewController

- (void)didInitialize {
[super didInitialize];
self.cornerRadius = [QMUIDialogViewController appearance].cornerRadius;
self.dialogViewMargins = UIEdgeInsetsConcat([QMUIDialogViewController appearance].dialogViewMargins, SafeAreaInsetsConstantForDeviceWithNotch);
self.maximumContentViewWidth = [QMUIDialogViewController appearance].maximumContentViewWidth;
self.backgroundColor = [QMUIDialogViewController appearance].backgroundColor;
self.titleTintColor = [QMUIDialogViewController appearance].titleTintColor;
self.titleLabelFont = [QMUIDialogViewController appearance].titleLabelFont;
self.titleLabelTextColor = [QMUIDialogViewController appearance].titleLabelTextColor;
self.subTitleLabelFont = [QMUIDialogViewController appearance].subTitleLabelFont;
self.subTitleLabelTextColor = [QMUIDialogViewController appearance].subTitleLabelTextColor;
self.headerSeparatorColor = [QMUIDialogViewController appearance].headerSeparatorColor;
self.headerViewHeight = [QMUIDialogViewController appearance].headerViewHeight;
self.headerViewBackgroundColor = [QMUIDialogViewController appearance].headerViewBackgroundColor;
self.contentViewMargins = [QMUIDialogViewController appearance].contentViewMargins;
self.contentViewBackgroundColor = [QMUIDialogViewController appearance].contentViewBackgroundColor;
self.footerSeparatorColor = [QMUIDialogViewController appearance].footerSeparatorColor;
self.footerViewHeight = [QMUIDialogViewController appearance].footerViewHeight;
self.footerViewBackgroundColor = [QMUIDialogViewController appearance].footerViewBackgroundColor;
self.buttonBackgroundColor = [QMUIDialogViewController appearance].buttonBackgroundColor;
self.buttonTitleAttributes = [QMUIDialogViewController appearance].buttonTitleAttributes;
self.buttonHighlightedBackgroundColor = [QMUIDialogViewController appearance].buttonHighlightedBackgroundColor;

[self qmui_applyAppearance];

_contentView = [[UIView alloc] init]; // 特地不使用setter,从而不要影响self.hasCustomContentView的默认值
self.contentView.backgroundColor = self.contentViewBackgroundColor;
Expand Down Expand Up @@ -464,8 +446,6 @@ @implementation QMUIDialogSelectionViewController
- (void)didInitialize {
[super didInitialize];

[self qmui_applyAppearance];

self.selectedItemIndex = QMUIDialogSelectionViewControllerSelectedItemIndexNone;
self.selectedItemIndexes = [[NSMutableSet alloc] init];

Expand Down Expand Up @@ -672,8 +652,6 @@ @implementation QMUIDialogTextFieldViewController
- (void)didInitialize {
[super didInitialize];

[self qmui_applyAppearance];

self.mutableTitleLabels = [[NSMutableArray alloc] init];
self.mutableTextFields = [[NSMutableArray alloc] init];
self.mutableSeparatorLayers = [[NSMutableArray alloc] init];
Expand Down
13 changes: 6 additions & 7 deletions QMUIKit/QMUICore/QMUIConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -311,21 +311,20 @@ - (void)setNavBarShadowImageColor:(UIColor *)navBarShadowImageColor {
}

- (void)configureNavBarShadowImage {
UIImage *shadowImage = nil;
if (self.navBarShadowImageColor) {
shadowImage = self.navBarShadowImage;
UIImage *shadowImage = self.navBarShadowImage;
if (shadowImage || self.navBarShadowImageColor) {
if (shadowImage) {
if (shadowImage.renderingMode != UIImageRenderingModeAlwaysOriginal) {
if (self.navBarShadowImageColor && shadowImage.renderingMode != UIImageRenderingModeAlwaysOriginal) {
shadowImage = [shadowImage qmui_imageWithTintColor:self.navBarShadowImageColor];
}
} else {
shadowImage = [UIImage qmui_imageWithColor:self.navBarShadowImageColor size:CGSizeMake(4, PixelOne) cornerRadius:0];
}

// 反向更新 NavBarShadowImage,以保证业务代码直接使用 NavBarShadowImage 宏能得到正确的图片
_navBarShadowImage = shadowImage;
}

// 反向更新 NavBarShadowImage,以保证业务代码直接使用 NavBarShadowImage 宏能得到正确的图片
_navBarShadowImage = shadowImage;

UINavigationBar.appearance.shadowImage = shadowImage;
[self.appearanceUpdatingNavigationControllers enumerateObjectsUsingBlock:^(UINavigationController * _Nonnull navigationController,NSUInteger idx, BOOL * _Nonnull stop) {
navigationController.navigationBar.shadowImage = shadowImage;
Expand Down
2 changes: 1 addition & 1 deletion QMUIKit/QMUIKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef QMUIKit_h
#define QMUIKit_h

static NSString * const QMUI_VERSION = @"4.1.0";
static NSString * const QMUI_VERSION = @"4.1.1";

#if __has_include("CAAnimation+QMUI.h")
#import "CAAnimation+QMUI.h"
Expand Down
2 changes: 1 addition & 1 deletion QMUIKit/UIKitExtensions/UIImage+QMUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ - (UIImage *)qmui_grayImage {

// 用 CGBitmapContextCreateImage 方式创建出来的图片,CGImageAlphaInfo 总是为 CGImageAlphaInfoNone,导致 qmui_opaque 与原图不一致,所以这里再做多一步
grayImage = [UIImage qmui_imageWithSize:grayImage.size opaque:NO scale:grayImage.scale actions:^(CGContextRef contextRef) {
[grayImage drawInRect:imageRect];
[grayImage drawInRect:CGRectMakeWithSize(grayImage.size)];
}];
}

Expand Down
4 changes: 2 additions & 2 deletions qmui.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1844,7 +1844,7 @@
"@loader_path/Frameworks",
);
MACH_O_TYPE = mh_dylib;
MARKETING_VERSION = 4.1.0;
MARKETING_VERSION = 4.1.1;
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.qmui.QMUIKit;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -1888,7 +1888,7 @@
"@loader_path/Frameworks",
);
MACH_O_TYPE = mh_dylib;
MARKETING_VERSION = 4.1.0;
MARKETING_VERSION = 4.1.1;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = com.qmui.QMUIKit;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down

0 comments on commit 413483a

Please sign in to comment.