Skip to content

Commit 95c98d5

Browse files
author
molicechen
committed
4.4.2
1 parent 9f67697 commit 95c98d5

File tree

15 files changed

+266
-128
lines changed

15 files changed

+266
-128
lines changed

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.4.1"
3+
s.version = "4.4.2"
44
s.summary = "致力于提高项目 UI 开发效率的解决方案"
55
s.description = <<-DESC
66
QMUI iOS 是一个致力于提高项目 UI 开发效率的解决方案,其设计目的是用于辅助快速搭建一个具备基本设计还原效果的 iOS 项目,同时利用自身提供的丰富控件及兼容处理, 让开发者能专注于业务需求而无需耗费精力在基础代码的设计上。不管是新项目的创建,或是已有项目的维护,均可使开发效率和项目质量得到大幅度提升。

QMUIKit/QMUIComponents/NavigationBarTransition/UINavigationBar+Transition.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,13 @@ - (void)layoutSubviews {
177177
self.qmui_backgroundView.frame = self.bounds;
178178
}
179179

180+
// NavBarRemoveBackgroundEffectAutomatically 在开启了 AutomaticCustomNavigationBarTransitionStyle 时可能对假 bar 无效
181+
// https://github.com/Tencent/QMUI_iOS/issues/1330
182+
- (void)didAddSubview:(UIView *)subview {
183+
[super didAddSubview:subview];
184+
if (subview == self.qmui_backgroundView) {
185+
[subview qmui_performSelector:NSSelectorFromString(@"updateBackground") withArguments:nil];
186+
}
187+
}
188+
180189
@end

QMUIKit/QMUIComponents/QMUIButton/QMUIButton.m

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,12 @@ @implementation QMUIButton
3131

3232
- (instancetype)initWithFrame:(CGRect)frame {
3333
if (self = [super initWithFrame:frame]) {
34+
[self didInitialize];
3435
self.tintColor = ButtonTintColor;
35-
if (!self.adjustsTitleTintColorAutomatically) {
36-
[self setTitleColor:self.tintColor forState:UIControlStateNormal];
37-
}
36+
[self setTitleColor:self.tintColor forState:UIControlStateNormal];// 初始化时 adjustsTitleTintColorAutomatically 还是 NO,所以这里手动把 titleColor 设置为 tintColor 的值
3837

3938
// iOS7以后的button,sizeToFit后默认会自带一个上下的contentInsets,为了保证按钮大小即为内容大小,这里直接去掉,改为一个最小的值。
4039
self.contentEdgeInsets = UIEdgeInsetsMake(CGFLOAT_MIN, 0, CGFLOAT_MIN, 0);
41-
42-
[self didInitialize];
4340
}
4441
return self;
4542
}
@@ -52,9 +49,6 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder {
5249
}
5350

5451
- (void)didInitialize {
55-
self.adjustsTitleTintColorAutomatically = NO;
56-
self.adjustsImageTintColorAutomatically = NO;
57-
5852
// 默认接管highlighted和disabled的表现,去掉系统默认的表现
5953
self.adjustsImageWhenHighlighted = NO;
6054
self.adjustsImageWhenDisabled = NO;
@@ -563,7 +557,10 @@ - (void)updateImageRenderingModeIfNeeded {
563557
for (NSNumber *number in states) {
564558
UIImage *image = [self imageForState:number.unsignedIntegerValue];
565559
if (!image) {
566-
return;
560+
continue;
561+
}
562+
if (number.unsignedIntegerValue != UIControlStateNormal && image == [self imageForState:UIControlStateNormal]) {
563+
continue;
567564
}
568565

569566
if (self.adjustsImageTintColorAutomatically) {

QMUIKit/QMUIComponents/QMUIModalPresentationViewController.m

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ - (void)showingAnimationWithCompletion:(void (^)(BOOL))completion {
452452
if (self.animationStyle == QMUIModalPresentationAnimationStyleFade) {
453453
self.dimmingView.alpha = 0.0;
454454
self.contentView.alpha = 0.0;
455-
[UIView animateWithDuration:.2 delay:0.0 options:QMUIViewAnimationOptionsCurveOut animations:^{
455+
[UIView animateWithDuration:.25 delay:0.0 options:QMUIViewAnimationOptionsCurveOut animations:^{
456456
self.dimmingView.alpha = 1.0;
457457
self.contentView.alpha = 1.0;
458458
if (self.shouldDimmedAppAutomatically) {
@@ -467,9 +467,9 @@ - (void)showingAnimationWithCompletion:(void (^)(BOOL))completion {
467467
} else if (self.animationStyle == QMUIModalPresentationAnimationStylePopup) {
468468
self.dimmingView.alpha = 0.0;
469469
self.contentView.transform = CGAffineTransformMakeScale(0, 0);
470-
[UIView animateWithDuration:.3 delay:0.0 options:QMUIViewAnimationOptionsCurveOut animations:^{
470+
[UIView animateWithDuration:.25 delay:0.0 options:QMUIViewAnimationOptionsCurveOut animations:^{
471471
self.dimmingView.alpha = 1.0;
472-
self.contentView.transform = CGAffineTransformMakeScale(1, 1);
472+
self.contentView.transform = CGAffineTransformIdentity;
473473
if (self.shouldDimmedAppAutomatically) {
474474
[QMUIHelper dimmedApplicationWindow];
475475
}
@@ -483,7 +483,7 @@ - (void)showingAnimationWithCompletion:(void (^)(BOOL))completion {
483483
} else if (self.animationStyle == QMUIModalPresentationAnimationStyleSlide) {
484484
self.dimmingView.alpha = 0.0;
485485
self.contentView.transform = CGAffineTransformMakeTranslation(0, CGRectGetHeight(self.view.bounds) - CGRectGetMinY(self.contentView.frame));
486-
[UIView animateWithDuration:.3 delay:0.0 options:QMUIViewAnimationOptionsCurveOut animations:^{
486+
[UIView animateWithDuration:.25 delay:0.0 options:QMUIViewAnimationOptionsCurveOut animations:^{
487487
self.dimmingView.alpha = 1.0;
488488
self.contentView.transform = CGAffineTransformIdentity;
489489
if (self.shouldDimmedAppAutomatically) {
@@ -517,7 +517,7 @@ - (void)showWithAnimated:(BOOL)animated completion:(void (^)(BOOL))completion {
517517

518518
- (void)hidingAnimationWithCompletion:(void (^)(BOOL))completion {
519519
if (self.animationStyle == QMUIModalPresentationAnimationStyleFade) {
520-
[UIView animateWithDuration:.2 delay:0.0 options:QMUIViewAnimationOptionsCurveOut animations:^{
520+
[UIView animateWithDuration:.25 delay:0.0 options:QMUIViewAnimationOptionsCurveOut animations:^{
521521
self.dimmingView.alpha = 0.0;
522522
self.contentView.alpha = 0.0;
523523
if (self.shouldDimmedAppAutomatically) {
@@ -531,9 +531,9 @@ - (void)hidingAnimationWithCompletion:(void (^)(BOOL))completion {
531531
}
532532
}];
533533
} else if (self.animationStyle == QMUIModalPresentationAnimationStylePopup) {
534-
[UIView animateWithDuration:.3 delay:0.0 options:QMUIViewAnimationOptionsCurveOut animations:^{
534+
[UIView animateWithDuration:.25 delay:0.0 options:QMUIViewAnimationOptionsCurveOut animations:^{
535535
self.dimmingView.alpha = 0.0;
536-
self.contentView.transform = CGAffineTransformMakeScale(0.0, 0.0);
536+
self.contentView.transform = CGAffineTransformMakeScale(0.01, 0.01);
537537
if (self.shouldDimmedAppAutomatically) {
538538
[QMUIHelper resetDimmedApplicationWindow];
539539
}
@@ -545,7 +545,7 @@ - (void)hidingAnimationWithCompletion:(void (^)(BOOL))completion {
545545
}
546546
}];
547547
} else if (self.animationStyle == QMUIModalPresentationAnimationStyleSlide) {
548-
[UIView animateWithDuration:.3 delay:0.0 options:QMUIViewAnimationOptionsCurveOut animations:^{
548+
[UIView animateWithDuration:.25 delay:0.0 options:QMUIViewAnimationOptionsCurveOut animations:^{
549549
self.dimmingView.alpha = 0.0;
550550
self.contentView.transform = CGAffineTransformMakeTranslation(0, CGRectGetHeight(self.view.bounds) - CGRectGetMinY(self.contentView.frame));
551551
if (self.shouldDimmedAppAutomatically) {

QMUIKit/QMUIComponents/QMUIScrollAnimator/QMUINavigationBarScrollingAnimator.m

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#import "QMUINavigationBarScrollingAnimator.h"
1717
#import "UIViewController+QMUI.h"
1818
#import "UIScrollView+QMUI.h"
19+
#import "UIView+QMUI.h"
1920

2021
@interface QMUINavigationBarScrollingAnimator ()
2122

@@ -34,16 +35,14 @@ - (instancetype)init {
3435
self.distanceToStopAnimation = 44;
3536

3637
self.didScrollBlock = ^(QMUINavigationBarScrollingAnimator * _Nonnull animator) {
37-
if (!animator.navigationBar) {
38-
UINavigationBar *navigationBar = [QMUIHelper visibleViewController].navigationController.navigationBar;
39-
if (navigationBar) {
40-
animator.navigationBar = navigationBar;
38+
UINavigationBar *navigationBar = animator.navigationBar;
39+
if (!navigationBar) {
40+
navigationBar = animator.scrollView.qmui_viewController.navigationController.navigationBar;
41+
if (!navigationBar) {
42+
NSLog(@"无法自动找到 UINavigationBar,或许此时 scrollView 所在的 viewController 已经不存在于 UINavigationController 里。");
43+
return;
4144
}
4245
}
43-
if (!animator.navigationBar) {
44-
NSLog(@"无法自动找到 UINavigationBar,请通过 %@.%@ 手动设置一个", NSStringFromClass(animator.class), NSStringFromSelector(@selector(navigationBar)));
45-
return;
46-
}
4746

4847
CGFloat progress = animator.progress;
4948

@@ -58,23 +57,23 @@ - (instancetype)init {
5857
} else {
5958
if (animator.backgroundImageBlock) {
6059
UIImage *backgroundImage = animator.backgroundImageBlock(animator, progress);
61-
[animator.navigationBar setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsDefault];
60+
[navigationBar setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsDefault];
6261
}
6362
if (animator.shadowImageBlock) {
6463
UIImage *shadowImage = animator.shadowImageBlock(animator, progress);
65-
animator.navigationBar.shadowImage = shadowImage;
64+
navigationBar.shadowImage = shadowImage;
6665
}
6766
if (animator.tintColorBlock) {
6867
UIColor *tintColor = animator.tintColorBlock(animator, progress);
69-
animator.navigationBar.tintColor = tintColor;
68+
navigationBar.tintColor = tintColor;
7069
}
7170
if (animator.titleViewTintColorBlock) {
7271
UIColor *tintColor = animator.titleViewTintColorBlock(animator, progress);
73-
animator.navigationBar.topItem.titleView.tintColor = tintColor;
72+
navigationBar.topItem.titleView.tintColor = tintColor;
7473
}
7574
if (animator.barTintColorBlock) {
7675
UIColor *barTintColor = animator.barTintColorBlock(animator, progress);
77-
animator.navigationBar.barTintColor = barTintColor;
76+
navigationBar.barTintColor = barTintColor;
7877
}
7978
if (animator.statusbarStyleBlock) {
8079
UIStatusBarStyle style = animator.statusbarStyleBlock(animator, progress);

QMUIKit/QMUIComponents/QMUIScrollAnimator/QMUINavigationBarScrollingSnapAnimator.m

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#import "QMUINavigationBarScrollingSnapAnimator.h"
1717
#import "UIViewController+QMUI.h"
1818
#import "UIScrollView+QMUI.h"
19+
#import "UIView+QMUI.h"
1920

2021
@interface QMUINavigationBarScrollingSnapAnimator ()
2122

@@ -32,16 +33,14 @@ - (instancetype)init {
3233
self.adjustsOffsetYWithInsetTopAutomatically = YES;
3334

3435
self.didScrollBlock = ^(QMUINavigationBarScrollingSnapAnimator * _Nonnull animator) {
35-
if (!animator.navigationBar) {
36-
UINavigationBar *navigationBar = [QMUIHelper visibleViewController].navigationController.navigationBar;
37-
if (navigationBar) {
38-
animator.navigationBar = navigationBar;
36+
UINavigationBar *navigationBar = animator.navigationBar;
37+
if (!navigationBar) {
38+
navigationBar = animator.scrollView.qmui_viewController.navigationController.navigationBar;
39+
if (!navigationBar) {
40+
NSLog(@"无法自动找到 UINavigationBar,或许此时 scrollView 所在的 viewController 已经不存在于 UINavigationController 里。");
41+
return;
3942
}
4043
}
41-
if (!animator.navigationBar) {
42-
NSLog(@"无法自动找到 UINavigationBar,请通过 %@.%@ 手动设置一个", NSStringFromClass(animator.class), NSStringFromSelector(@selector(navigationBar)));
43-
return;
44-
}
4544

4645
if (animator.animationBlock) {
4746
if (animator.offsetYReached) {

QMUIKit/QMUIComponents/QMUITextField.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
/**
3131
* 配合 `maximumTextLength` 属性使用,在输入文字超过限制时被调用。
32-
* @warning 在 UIControlEventEditingChanged 里也会触发文字长度拦截,由于此时 textField 的文字已经改变完,所以无法得知发生改变的文本位置及改变的文本内容,所以此时 range 和 replacementString 这两个参数的值也会比较特殊,具体请看参数讲解。QMUI/QMUIKit/QMUIComponents/QMUITextField.m
32+
* @warning 在 UIControlEventEditingChanged 里也会触发文字长度拦截,由于此时 textField 的文字已经改变完,所以无法得知发生改变的文本位置及改变的文本内容,所以此时 range 和 replacementString 这两个参数的值也会比较特殊,具体请看参数讲解。
3333
*
3434
* @param textField 触发的 textField
3535
* @param range 要变化的文字的位置,如果在 UIControlEventEditingChanged 里,这里的 range 也即文字变化后的 range,所以可能比最大长度要大。

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.4.1";
16+
static NSString * const QMUI_VERSION = @"4.4.2";
1717

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

QMUIKit/UIKitExtensions/NSAttributedString+QMUI.m

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,6 @@
2424

2525
@implementation NSAttributedString (QMUI)
2626

27-
+ (void)load {
28-
static dispatch_once_t onceToken;
29-
dispatch_once(&onceToken, ^{
30-
31-
// 类簇对不同的init方法对应不同的私有class,所以要用实例来得到真正的class
32-
OverrideImplementation([[[NSAttributedString alloc] initWithString:@""] class], @selector(initWithString:), ^id(__unsafe_unretained Class originClass, SEL originCMD, IMP (^originalIMPProvider)(void)) {
33-
return ^NSAttributedString *(NSAttributedString *selfObject, NSString *str) {
34-
35-
str = str ?: @"";
36-
37-
// call super
38-
NSAttributedString *(*originSelectorIMP)(id, SEL, NSString *);
39-
originSelectorIMP = (NSAttributedString * (*)(id, SEL, NSString *))originalIMPProvider();
40-
NSAttributedString * result = originSelectorIMP(selfObject, originCMD, str);
41-
42-
return result;
43-
};
44-
});
45-
46-
OverrideImplementation([[[NSAttributedString alloc] initWithString:@"" attributes:nil] class], @selector(initWithString:attributes:), ^id(__unsafe_unretained Class originClass, SEL originCMD, IMP (^originalIMPProvider)(void)) {
47-
return ^NSAttributedString *(NSAttributedString *selfObject, NSString *str, NSDictionary<NSString *,id> *attrs) {
48-
str = str ?: @"";
49-
50-
// call super
51-
NSAttributedString *(*originSelectorIMP)(id, SEL, NSString *, NSDictionary<NSString *,id> *);
52-
originSelectorIMP = (NSAttributedString *(*)(id, SEL, NSString *, NSDictionary<NSString *,id> *))originalIMPProvider();
53-
NSAttributedString *result = originSelectorIMP(selfObject, originCMD, str, attrs);
54-
55-
return result;
56-
};
57-
});
58-
});
59-
}
60-
6127
+ (instancetype)qmui_attributedStringWithImage:(UIImage *)image {
6228
return [self qmui_attributedStringWithImage:image alignByAttributes:image.qmui_stringAttributes];
6329
}
@@ -139,43 +105,6 @@ - (instancetype)qmui_stringByRemoveLastCharacter {
139105

140106
@end
141107

142-
@implementation NSMutableAttributedString (QMUI)
143-
144-
+ (void)load {
145-
static dispatch_once_t onceToken;
146-
dispatch_once(&onceToken, ^{
147-
// 类簇对不同的init方法对应不同的私有class,所以要用实例来得到真正的class
148-
OverrideImplementation([[[NSMutableAttributedString alloc] initWithString:@""] class], @selector(initWithString:), ^id(__unsafe_unretained Class originClass, SEL originCMD, IMP (^originalIMPProvider)(void)) {
149-
return ^NSMutableAttributedString *(NSMutableAttributedString *selfObject, NSString *str) {
150-
151-
str = str ?: @"";
152-
153-
// call super
154-
NSMutableAttributedString *(*originSelectorIMP)(id, SEL, NSString *);
155-
originSelectorIMP = (NSMutableAttributedString *(*)(id, SEL, NSString *))originalIMPProvider();
156-
NSMutableAttributedString *result = originSelectorIMP(selfObject, originCMD, str);
157-
158-
return result;
159-
};
160-
});
161-
162-
OverrideImplementation([[[NSMutableAttributedString alloc] initWithString:@"" attributes:nil] class], @selector(initWithString:attributes:), ^id(__unsafe_unretained Class originClass, SEL originCMD, IMP (^originalIMPProvider)(void)) {
163-
return ^NSMutableAttributedString *(NSMutableAttributedString *selfObject, NSString *str, NSDictionary<NSString *,id> *attrs) {
164-
str = str ?: @"";
165-
166-
// call super
167-
NSMutableAttributedString *(*originSelectorIMP)(id, SEL, NSString *, NSDictionary<NSString *,id> *);
168-
originSelectorIMP = (NSMutableAttributedString *(*)(id, SEL, NSString *, NSDictionary<NSString *,id> *))originalIMPProvider();
169-
NSMutableAttributedString *result = originSelectorIMP(selfObject, originCMD, str, attrs);
170-
171-
return result;
172-
};
173-
});
174-
});
175-
}
176-
177-
@end
178-
179108
@implementation UIImage (QMUI_NSAttributedStringSupports)
180109

181110
+ (void)load {

QMUIKit/UIKitExtensions/NSObject+QMUI.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,16 @@ NS_ASSUME_NONNULL_BEGIN
296296
@interface NSObject (QMUI_Debug)
297297

298298
/// 获取当前对象的所有 @property、方法,父类的方法也会分别列出
299-
- (NSString *)qmui_methodList;
299+
@property(nonatomic, copy, readonly) NSString *qmui_methodList;
300300

301301
/// 获取当前对象的所有 @property、方法,不包含父类的
302-
- (NSString *)qmui_shortMethodList;
302+
@property(nonatomic, copy, readonly) NSString *qmui_shortMethodList;
303303

304304
/// 获取当前对象的所有 Ivar 变量
305-
- (NSString *)qmui_ivarList;
305+
@property(nonatomic, copy, readonly) NSString *qmui_ivarList;
306+
307+
/// 获取当前 UIView 层级树信息(只对 UIView 有效)
308+
@property(nonatomic, copy, readonly) NSString *qmui_viewInfo;
306309
@end
307310

308311
@interface NSThread (QMUI_KVC)

0 commit comments

Comments
 (0)