Skip to content

Commit 3f62fa4

Browse files
committed
2.9.0
1 parent be231f9 commit 3f62fa4

54 files changed

Lines changed: 842 additions & 299 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

QMUIConfigurationTemplate/QMUIConfigurationTemplate.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ - (void)applyConfigurationTemplate {
9393
QMUICMI.navBarLoadingMarginRight = 3; // NavBarLoadingMarginRight : QMUINavigationTitleView 里左边 loading 的右边距
9494
QMUICMI.navBarAccessoryViewMarginLeft = 5; // NavBarAccessoryViewMarginLeft : QMUINavigationTitleView 里右边 accessoryView 的左边距
9595
QMUICMI.navBarActivityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;// NavBarActivityIndicatorViewStyle : QMUINavigationTitleView 里左边 loading 的主题
96-
QMUICMI.navBarAccessoryViewTypeDisclosureIndicatorImage = [UIImage qmui_imageWithShape:QMUIImageShapeTriangle size:CGSizeMake(8, 5) tintColor:UIColorWhite]; // NavBarAccessoryViewTypeDisclosureIndicatorImage : QMUINavigationTitleView 右边箭头的图片
96+
QMUICMI.navBarAccessoryViewTypeDisclosureIndicatorImage = [[UIImage qmui_imageWithShape:QMUIImageShapeTriangle size:CGSizeMake(8, 5) tintColor:nil] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; // NavBarAccessoryViewTypeDisclosureIndicatorImage : QMUINavigationTitleView 右边箭头的图片
9797

9898
#pragma mark - TabBar
9999

@@ -200,6 +200,7 @@ - (void)applyConfigurationTemplate {
200200

201201
#pragma mark - Others
202202

203+
QMUICMI.automaticCustomNavigationBarTransitionStyle = NO; // AutomaticCustomNavigationBarTransitionStyle : 界面 push/pop 时是否要自动根据两个界面的 barTintColor/backgroundImage/shadowImage 的样式差异来决定是否使用自定义的导航栏效果
203204
QMUICMI.supportedOrientationMask = UIInterfaceOrientationMaskAll; // SupportedOrientationMask : 默认支持的横竖屏方向
204205
QMUICMI.automaticallyRotateDeviceOrientation = NO; // AutomaticallyRotateDeviceOrientation : 是否在界面切换或 viewController.supportedOrientationMask 发生变化时自动旋转屏幕
205206
QMUICMI.statusbarStyleLightInitially = NO; // StatusbarStyleLightInitially : 默认的状态栏内容是否使用白色,默认为 NO,也即黑色
@@ -208,6 +209,7 @@ - (void)applyConfigurationTemplate {
208209
QMUICMI.preventConcurrentNavigationControllerTransitions = YES; // PreventConcurrentNavigationControllerTransitions : 自动保护 QMUINavigationController 在上一次 push/pop 尚未结束的时候就进行下一次 push/pop 的行为,避免产生 crash
209210
QMUICMI.navigationBarHiddenInitially = NO; // NavigationBarHiddenInitially : QMUINavigationControllerDelegate preferredNavigationBarHidden 的初始值,默认为NO
210211
QMUICMI.shouldFixTabBarTransitionBugInIPhoneX = NO; // ShouldFixTabBarTransitionBugInIPhoneX : 是否需要自动修复 iOS 11 下,iPhone X 的设备在 push 界面时,tabBar 会瞬间往上跳的 bug
212+
QMUICMI.shouldAssertResizableImageCapInsetsError = YES; // ShouldAssertResizableImageCapInsetsError : UIImage (QMUI) 里的 resizableImage 遇到错误的 inset 值时是否需要以 NSAssert 的方式的方式提醒,默认为 NO,NO 则用 QMUILog
211213
QMUICMI.sendAnalyticsToQMUITeam = YES; // SendAnalyticsToQMUITeam : 是否允许在 DEBUG 模式下上报 Bundle Identifier 和 Display Name 给 QMUI 统计用
212214
}
213215

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

QMUIKit/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>2.9.0</string>
18+
<string>2.9.1</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSPrincipalClass</key>

QMUIKit/QMUIComponents/NavigationBarTransition/UINavigationController+NavigationBarTransition.m

Lines changed: 151 additions & 73 deletions
Large diffs are not rendered by default.

QMUIKit/QMUIComponents/QMUIAlertController.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,6 @@ - (void)didClickAlertAction:(QMUIAlertAction *)alertAction {
11621162
[self hideWithAnimated:YES completion:^{
11631163
if (alertAction.handler) {
11641164
alertAction.handler(self, alertAction);
1165-
alertAction.handler = nil;
11661165
}
11671166
}];
11681167
}

QMUIKit/QMUIComponents/QMUIButton/QMUINavigationButton.m

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ - (void)renderButtonStyle {
6868
self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
6969
self.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
7070
self.qmui_automaticallyAdjustTouchHighlightedInScrollView = YES;
71+
if (self.type == QMUINavigationButtonTypeImage) {
72+
if (@available(iOS 11, *)) {
73+
// 让 iOS 11 及以后也能走到 alignmentRectInsets,iOS 10 及以前的系统就算不置为 NO 也可以走到 alignmentRectInsets,从而保证 image 类型的按钮的布局、间距与系统的保持一致
74+
self.translatesAutoresizingMaskIntoConstraints = NO;
75+
}
76+
}
7177

7278
// 系统默认对 highlighted 和 disabled 的图片的表现是变身色,但 UIBarButtonItem 是 alpha,为了与 UIBarButtonItem 表现一致,这里禁用了 UIButton 默认的行为,然后通过重写 setImage:forState:,自动将 normal image 处理为对应的 highlighted image 和 disabled image
7379
self.adjustsImageWhenHighlighted = NO;
@@ -88,10 +94,14 @@ - (void)renderButtonStyle {
8894
}
8995
break;
9096
case QMUINavigationButtonTypeBack: {
91-
UIImage *backIndicatorImage = NavBarBackIndicatorImage;
97+
UIImage *backIndicatorImage = [UINavigationBar appearance].backIndicatorImage;
9298
if (!backIndicatorImage) {
93-
// 配置表没有自定义的图片,则按照系统的返回按钮图片样式创建一张
94-
backIndicatorImage = [UIImage qmui_imageWithShape:QMUIImageShapeNavBack size:CGSizeMake(13, 23) lineWidth:3 tintColor:NavBarTintColor];
99+
// 配置表没有自定义的图片,则按照系统的返回按钮图片样式创建一张,颜色按照 tintColor 来
100+
UIColor *tintColor = QMUICMIActivated ? NavBarTintColor : ({
101+
UIView *view = [[UIView alloc] init];
102+
view.tintColor;
103+
});
104+
backIndicatorImage = [UIImage qmui_imageWithShape:QMUIImageShapeNavBack size:CGSizeMake(13, 23) lineWidth:3 tintColor:tintColor];
95105
}
96106
[self setImage:backIndicatorImage forState:UIControlStateNormal];
97107
[self setImage:[backIndicatorImage qmui_imageWithAlpha:NavBarHighlightedAlpha] forState:UIControlStateHighlighted];
@@ -151,7 +161,7 @@ - (void)tintColorDidChange {
151161
[self setTitleColor:[self.tintColor colorWithAlphaComponent:NavBarDisabledAlpha] forState:UIControlStateDisabled];
152162
}
153163

154-
// 对按钮内容添加偏移,让UIBarButtonItem适配最新设备的系统行为,统一位置。注意 iOS 11 不会走到这里来
164+
// 对按钮内容添加偏移,让UIBarButtonItem适配最新设备的系统行为,统一位置。注意 iOS 11 及以后,只有 image 类型的才会走进来
155165
- (UIEdgeInsets)alignmentRectInsets {
156166

157167
UIEdgeInsets insets = [super alignmentRectInsets];
@@ -246,7 +256,9 @@ + (instancetype)qmui_backItemWithTarget:(nullable id)target action:(nullable SEL
246256
}
247257

248258
+ (instancetype)qmui_closeItemWithTarget:(nullable id)target action:(nullable SEL)action {
249-
return [[UIBarButtonItem alloc] initWithImage:NavBarCloseButtonImage style:UIBarButtonItemStylePlain target:target action:action];
259+
UIBarButtonItem *closeItem = [[UIBarButtonItem alloc] initWithImage:NavBarCloseButtonImage style:UIBarButtonItemStylePlain target:target action:action];
260+
closeItem.accessibilityLabel = @"关闭";
261+
return closeItem;
250262
}
251263

252264
+ (instancetype)qmui_fixedSpaceItemWithWidth:(CGFloat)width {

QMUIKit/QMUIComponents/QMUIDialogViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
;//
1+
//
22
// QMUIDialogViewController.m
33
// WeRead
44
//

QMUIKit/QMUIComponents/QMUIKeyboardManager.m

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ - (CGFloat)heightInView:(UIView *)view {
170170
return [self height];
171171
}
172172
CGRect keyboardRect = [QMUIKeyboardManager convertKeyboardRect:_endFrame toView:view];
173-
CGRect visibleRect = CGRectIntersection(view.bounds, keyboardRect);
173+
CGRect visibleRect = CGRectIntersection(CGRectFlatted(view.bounds), CGRectFlatted(keyboardRect));
174174
if (!CGRectIsValidated(visibleRect)) {
175175
return 0;
176176
}
@@ -312,8 +312,14 @@ - (void)addKeyboardNotification {
312312
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidChangeFrameNotification:) name:UIKeyboardDidChangeFrameNotification object:nil];
313313
}
314314

315-
- (BOOL)isAppActive {
316-
return [[UIApplication sharedApplication] applicationState] == UIApplicationStateActive;
315+
- (BOOL)isAppActive:(NSNotification *)notification {
316+
if ([[UIApplication sharedApplication] applicationState] != UIApplicationStateActive) {
317+
return NO;
318+
}
319+
if (![[notification.userInfo valueForKey:UIKeyboardIsLocalUserInfoKey] boolValue]) {
320+
return NO;
321+
}
322+
return YES;
317323
}
318324

319325
- (void)keyboardWillShowNotification:(NSNotification *)notification {
@@ -322,7 +328,7 @@ - (void)keyboardWillShowNotification:(NSNotification *)notification {
322328
QMUILog(NSStringFromClass(self.class), @"keyboardWillShowNotification - %@", self);
323329
}
324330

325-
if (![self isAppActive]) {
331+
if (![self isAppActive:notification]) {
326332
QMUILog(NSStringFromClass(self.class), @"app is not active");
327333
return;
328334
}
@@ -346,7 +352,7 @@ - (void)keyboardDidShowNotification:(NSNotification *)notification {
346352
QMUILog(NSStringFromClass(self.class), @"keyboardDidShowNotification - %@", self);
347353
}
348354

349-
if (![self isAppActive]) {
355+
if (![self isAppActive:notification]) {
350356
QMUILog(NSStringFromClass(self.class), @"app is not active");
351357
return;
352358
}
@@ -371,7 +377,7 @@ - (void)keyboardWillHideNotification:(NSNotification *)notification {
371377
QMUILog(NSStringFromClass(self.class), @"keyboardWillHideNotification - %@", self);
372378
}
373379

374-
if (![self isAppActive]) {
380+
if (![self isAppActive:notification]) {
375381
QMUILog(NSStringFromClass(self.class), @"app is not active");
376382
return;
377383
}
@@ -395,7 +401,7 @@ - (void)keyboardDidHideNotification:(NSNotification *)notification {
395401
QMUILog(NSStringFromClass(self.class), @"keyboardDidHideNotification - %@", self);
396402
}
397403

398-
if (![self isAppActive]) {
404+
if (![self isAppActive:notification]) {
399405
QMUILog(NSStringFromClass(self.class), @"app is not active");
400406
return;
401407
}
@@ -421,7 +427,7 @@ - (void)keyboardWillChangeFrameNotification:(NSNotification *)notification {
421427
QMUILog(NSStringFromClass(self.class), @"keyboardWillChangeFrameNotification - %@", self);
422428
}
423429

424-
if (![self isAppActive]) {
430+
if (![self isAppActive:notification]) {
425431
QMUILog(NSStringFromClass(self.class), @"app is not active");
426432
return;
427433
}
@@ -448,7 +454,7 @@ - (void)keyboardDidChangeFrameNotification:(NSNotification *)notification {
448454
QMUILog(NSStringFromClass(self.class), @"keyboardDidChangeFrameNotification - %@", self);
449455
}
450456

451-
if (![self isAppActive]) {
457+
if (![self isAppActive:notification]) {
452458
QMUILog(NSStringFromClass(self.class), @"app is not active");
453459
return;
454460
}
@@ -524,6 +530,7 @@ + (void)animateWithAnimated:(BOOL)animated keyboardUserInfo:(QMUIKeyboardUserInf
524530

525531
+ (void)handleKeyboardNotificationWithUserInfo:(QMUIKeyboardUserInfo *)keyboardUserInfo showBlock:(void (^)(QMUIKeyboardUserInfo *keyboardUserInfo))showBlock hideBlock:(void (^)(QMUIKeyboardUserInfo *keyboardUserInfo))hideBlock {
526532
// 专门处理 iPad Pro 在键盘完全不显示的情况(不会调用willShow,所以通过是否focus来判断)
533+
// iPhoneX Max 这里键盘高度不是0,而是一个很小的值
527534
if ([QMUIKeyboardManager visibleKeyboardHeight] <= 0 && !keyboardUserInfo.isTargetResponderFocused) {
528535
if (hideBlock) {
529536
hideBlock(keyboardUserInfo);
@@ -613,7 +620,7 @@ + (CGRect)convertKeyboardRect:(CGRect)rect toView:(UIView *)view {
613620

614621
+ (CGFloat)distanceFromMinYToBottomInView:(UIView *)view keyboardRect:(CGRect)rect {
615622
rect = [self convertKeyboardRect:rect toView:view];
616-
CGFloat distance = CGRectGetHeight(view.bounds) - CGRectGetMinY(rect);
623+
CGFloat distance = CGRectGetHeight(CGRectFlatted(view.bounds)) - CGRectGetMinY(rect);
617624
return distance;
618625
}
619626

@@ -666,7 +673,7 @@ + (BOOL)isKeyboardVisible {
666673
if (!keyboardView || !keyboardWindow) {
667674
return NO;
668675
}
669-
CGRect rect = CGRectIntersection(keyboardWindow.bounds, keyboardView.frame);
676+
CGRect rect = CGRectIntersection(CGRectFlatted(keyboardWindow.bounds), CGRectFlatted(keyboardView.frame));
670677
if (CGRectIsValidated(rect) && !CGRectIsEmpty(rect)) {
671678
return YES;
672679
}
@@ -680,9 +687,9 @@ + (CGRect)currentKeyboardFrame {
680687
}
681688
UIWindow *keyboardWindow = keyboardView.window;
682689
if (keyboardWindow) {
683-
return [keyboardWindow convertRect:keyboardView.frame toWindow:nil];
690+
return [keyboardWindow convertRect:CGRectFlatted(keyboardView.frame) toWindow:nil];
684691
} else {
685-
return keyboardView.frame;
692+
return CGRectFlatted(keyboardView.frame);
686693
}
687694
}
688695

@@ -692,7 +699,7 @@ + (CGFloat)visibleKeyboardHeight {
692699
if (!keyboardView || !keyboardWindow) {
693700
return 0;
694701
} else {
695-
CGRect visibleRect = CGRectIntersection(keyboardWindow.bounds, keyboardView.frame);
702+
CGRect visibleRect = CGRectIntersection(CGRectFlatted(keyboardWindow.bounds), CGRectFlatted(keyboardView.frame));
696703
if (CGRectIsValidated(visibleRect)) {
697704
return CGRectGetHeight(visibleRect);
698705
}

QMUIKit/QMUIComponents/QMUIMarqueeLabel.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
/// 用于控制首尾连接的文字之间的间距,默认为 40pt。
2626
@property(nonatomic, assign) IBInspectable CGFloat spacingBetweenHeadToTail;
2727

28+
// 用于控制左和右边两端的渐变区域的百分比,默认为 0.2,则是 20% 宽。
29+
@property(nonatomic, assign) IBInspectable CGFloat fadeWidthPercent;
30+
2831
/**
2932
* 自动判断 label 的 frame 是否超出当前的 UIWindow 可视范围,超出则自动停止动画。默认为 YES。
3033
* @warning 某些场景并无法触发这个自动检测(例如直接调整 label.superview 的 frame 而不是 label 自身的 frame),这种情况暂不处理。

QMUIKit/QMUIComponents/QMUIMarqueeLabel.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ - (void)didMoveToWindow {
8181
[self checkIfShouldShowGradientLayer];
8282
}
8383

84+
- (void)setFadeWidthPercent:(CGFloat)fadeWidthPercent {
85+
if (!betweenOrEqual(0.0, fadeWidthPercent, 1.0)) {
86+
return;
87+
}
88+
_fadeWidthPercent = fadeWidthPercent;
89+
90+
self.fadeEndPercent = fadeWidthPercent;
91+
}
92+
8493
- (void)setText:(NSString *)text {
8594
[super setText:text];
8695
self.offsetX = 0;

0 commit comments

Comments
 (0)