Skip to content

Commit 413483a

Browse files
committed
4.1.1
1 parent 9e366c0 commit 413483a

12 files changed

Lines changed: 31 additions & 57 deletions

File tree

QMUIConfigurationTemplate/QMUIConfigurationTemplate.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ - (void)applyConfigurationTemplate {
9494
QMUICMI.navBarButtonFontBold = nil; // NavBarButtonFontBold : QMUINavigationButtonTypeBold 的字体
9595
QMUICMI.navBarBackgroundImage = nil; // NavBarBackgroundImage : UINavigationBar 的背景图
9696
QMUICMI.navBarShadowImage = nil; // NavBarShadowImage : UINavigationBar.shadowImage,也即导航栏底部那条分隔线,配合 NavBarShadowImageColor 使用。
97-
QMUICMI.navBarShadowImageColor = nil; // NavBarShadowImageColor : UINavigationBar.shadowImage 的颜色,如果为 nil,则显示系统默认 shadowImage,如果为全透明,则不显示 shadowImage,如果为除了 nil 和全透明外的其他颜色,则会将这个颜色叠加到 NavBarShadowImage 上显示出来,如果不存在 NavBarShadowImage,则使用一张 1px 高的图片作为默认图
97+
QMUICMI.navBarShadowImageColor = nil; // NavBarShadowImageColor : UINavigationBar.shadowImage 的颜色,如果为 nil,则使用 NavBarShadowImage 的值,如果 NavBarShadowImage 也为 nil,则使用系统默认的分隔线。如果不为 nil,而 NavBarShadowImage 为 nil,则自动创建一张 1px 高的图并将其设置为 NavBarShadowImageColor 的颜色然后设置上去,如果 NavBarShadowImage 不为 nil 且 renderingMode 不为 UIImageRenderingModeAlwaysOriginal,则将 NavBarShadowImage 设置为 NavBarShadowImageColor 的颜色然后设置上去
9898
QMUICMI.navBarBarTintColor = nil; // NavBarBarTintColor : UINavigationBar.barTintColor,也即背景色
9999
QMUICMI.navBarStyle = UIBarStyleDefault; // NavBarStyle : UINavigationBar 的 barStyle
100100
QMUICMI.navBarTintColor = nil; // NavBarTintColor : QMUINavigationController.navigationBar 的 tintColor,也即导航栏上面的按钮颜色,由于 tintColor 不支持 appearance,所以这里只支持 QMUINavigationController

QMUIKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "QMUIKit"
3-
s.version = "4.1.0"
3+
s.version = "4.1.1"
44
s.summary = "致力于提高项目 UI 开发效率的解决方案"
55
s.description = <<-DESC
66
QMUI iOS 是一个致力于提高项目 UI 开发效率的解决方案,其设计目的是用于辅助快速搭建一个具备基本设计还原效果的 iOS 项目,同时利用自身提供的丰富控件及兼容处理, 让开发者能专注于业务需求而无需耗费精力在基础代码的设计上。不管是新项目的创建,或是已有项目的维护,均可使开发效率和项目质量得到大幅度提升。

QMUIKit/QMUIComponents/ImagePickerLibrary/QMUIAlbumViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ @implementation QMUIAlbumViewController
136136
- (void)didInitialize {
137137
[super didInitialize];
138138
_shouldShowDefaultLoadingView = YES;
139-
self.albumTableViewCellHeight = [QMUIAlbumViewController appearance].albumTableViewCellHeight;
139+
[self qmui_applyAppearance];
140140
}
141141

142142
- (void)setupNavigationItems {

QMUIKit/QMUIComponents/ImagePickerLibrary/QMUIImagePickerCollectionViewCell.m

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#import "QMUIButton.h"
2424
#import "UIView+QMUI.h"
2525
#import "NSString+QMUI.h"
26+
#import "QMUIAppearance.h"
2627

2728
@interface QMUIImagePickerCollectionViewCell ()
2829

@@ -55,14 +56,7 @@ - (instancetype)initWithFrame:(CGRect)frame {
5556
self = [super initWithFrame:frame];
5657
if (self) {
5758
[self initImagePickerCollectionViewCellUI];
58-
self.favoriteImage = [QMUIImagePickerCollectionViewCell appearance].favoriteImage;
59-
self.favoriteImageMargins = [QMUIImagePickerCollectionViewCell appearance].favoriteImageMargins;
60-
self.checkboxImage = [QMUIImagePickerCollectionViewCell appearance].checkboxImage;
61-
self.checkboxCheckedImage = [QMUIImagePickerCollectionViewCell appearance].checkboxCheckedImage;
62-
self.checkboxButtonMargins = [QMUIImagePickerCollectionViewCell appearance].checkboxButtonMargins;
63-
self.videoDurationLabelFont = [QMUIImagePickerCollectionViewCell appearance].videoDurationLabelFont;
64-
self.videoDurationLabelTextColor = [QMUIImagePickerCollectionViewCell appearance].videoDurationLabelTextColor;
65-
self.videoDurationLabelMargins = [QMUIImagePickerCollectionViewCell appearance].videoDurationLabelMargins;
59+
[self qmui_applyAppearance];
6660
}
6761
return self;
6862
}

QMUIKit/QMUIComponents/NavigationBarTransition/UINavigationController+NavigationBarTransition.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,9 @@ - (void)renderNavigationStyleInViewController:(UIViewController *)viewController
338338

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

348346
// 导航栏上控件的主题色

QMUIKit/QMUIComponents/QMUIAppearance.h

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

QMUIKit/QMUIComponents/QMUIAppearance.m

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,18 @@ + (instancetype)appearance;
4848

4949
@implementation NSObject (QMUIAppearnace)
5050

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

QMUIKit/QMUIComponents/QMUIDialogViewController.m

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,8 @@ @implementation QMUIDialogViewController
7474

7575
- (void)didInitialize {
7676
[super didInitialize];
77-
self.cornerRadius = [QMUIDialogViewController appearance].cornerRadius;
78-
self.dialogViewMargins = UIEdgeInsetsConcat([QMUIDialogViewController appearance].dialogViewMargins, SafeAreaInsetsConstantForDeviceWithNotch);
79-
self.maximumContentViewWidth = [QMUIDialogViewController appearance].maximumContentViewWidth;
80-
self.backgroundColor = [QMUIDialogViewController appearance].backgroundColor;
81-
self.titleTintColor = [QMUIDialogViewController appearance].titleTintColor;
82-
self.titleLabelFont = [QMUIDialogViewController appearance].titleLabelFont;
83-
self.titleLabelTextColor = [QMUIDialogViewController appearance].titleLabelTextColor;
84-
self.subTitleLabelFont = [QMUIDialogViewController appearance].subTitleLabelFont;
85-
self.subTitleLabelTextColor = [QMUIDialogViewController appearance].subTitleLabelTextColor;
86-
self.headerSeparatorColor = [QMUIDialogViewController appearance].headerSeparatorColor;
87-
self.headerViewHeight = [QMUIDialogViewController appearance].headerViewHeight;
88-
self.headerViewBackgroundColor = [QMUIDialogViewController appearance].headerViewBackgroundColor;
89-
self.contentViewMargins = [QMUIDialogViewController appearance].contentViewMargins;
90-
self.contentViewBackgroundColor = [QMUIDialogViewController appearance].contentViewBackgroundColor;
91-
self.footerSeparatorColor = [QMUIDialogViewController appearance].footerSeparatorColor;
92-
self.footerViewHeight = [QMUIDialogViewController appearance].footerViewHeight;
93-
self.footerViewBackgroundColor = [QMUIDialogViewController appearance].footerViewBackgroundColor;
94-
self.buttonBackgroundColor = [QMUIDialogViewController appearance].buttonBackgroundColor;
95-
self.buttonTitleAttributes = [QMUIDialogViewController appearance].buttonTitleAttributes;
96-
self.buttonHighlightedBackgroundColor = [QMUIDialogViewController appearance].buttonHighlightedBackgroundColor;
77+
78+
[self qmui_applyAppearance];
9779

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

467-
[self qmui_applyAppearance];
468-
469449
self.selectedItemIndex = QMUIDialogSelectionViewControllerSelectedItemIndexNone;
470450
self.selectedItemIndexes = [[NSMutableSet alloc] init];
471451

@@ -672,8 +652,6 @@ @implementation QMUIDialogTextFieldViewController
672652
- (void)didInitialize {
673653
[super didInitialize];
674654

675-
[self qmui_applyAppearance];
676-
677655
self.mutableTitleLabels = [[NSMutableArray alloc] init];
678656
self.mutableTextFields = [[NSMutableArray alloc] init];
679657
self.mutableSeparatorLayers = [[NSMutableArray alloc] init];

QMUIKit/QMUICore/QMUIConfiguration.m

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -311,21 +311,20 @@ - (void)setNavBarShadowImageColor:(UIColor *)navBarShadowImageColor {
311311
}
312312

313313
- (void)configureNavBarShadowImage {
314-
UIImage *shadowImage = nil;
315-
if (self.navBarShadowImageColor) {
316-
shadowImage = self.navBarShadowImage;
314+
UIImage *shadowImage = self.navBarShadowImage;
315+
if (shadowImage || self.navBarShadowImageColor) {
317316
if (shadowImage) {
318-
if (shadowImage.renderingMode != UIImageRenderingModeAlwaysOriginal) {
317+
if (self.navBarShadowImageColor && shadowImage.renderingMode != UIImageRenderingModeAlwaysOriginal) {
319318
shadowImage = [shadowImage qmui_imageWithTintColor:self.navBarShadowImageColor];
320319
}
321320
} else {
322321
shadowImage = [UIImage qmui_imageWithColor:self.navBarShadowImageColor size:CGSizeMake(4, PixelOne) cornerRadius:0];
323322
}
323+
324+
// 反向更新 NavBarShadowImage,以保证业务代码直接使用 NavBarShadowImage 宏能得到正确的图片
325+
_navBarShadowImage = shadowImage;
324326
}
325327

326-
// 反向更新 NavBarShadowImage,以保证业务代码直接使用 NavBarShadowImage 宏能得到正确的图片
327-
_navBarShadowImage = shadowImage;
328-
329328
UINavigationBar.appearance.shadowImage = shadowImage;
330329
[self.appearanceUpdatingNavigationControllers enumerateObjectsUsingBlock:^(UINavigationController * _Nonnull navigationController,NSUInteger idx, BOOL * _Nonnull stop) {
331330
navigationController.navigationBar.shadowImage = shadowImage;

QMUIKit/QMUIKit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#ifndef QMUIKit_h
1414
#define QMUIKit_h
1515

16-
static NSString * const QMUI_VERSION = @"4.1.0";
16+
static NSString * const QMUI_VERSION = @"4.1.1";
1717

1818
#if __has_include("CAAnimation+QMUI.h")
1919
#import "CAAnimation+QMUI.h"

0 commit comments

Comments
 (0)