Skip to content

Commit 94c5dcf

Browse files
author
molicechen
committed
4.4.1
1 parent 1230a57 commit 94c5dcf

30 files changed

+828
-259
lines changed

QMUIConfigurationTemplate/QMUIConfigurationTemplate.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ - (void)applyConfigurationTemplate {
5151
QMUICMI.testColorGreen = UIColorMakeWithRGBA(0, 255, 0, .3);
5252
QMUICMI.testColorBlue = UIColorMakeWithRGBA(0, 0, 255, .3);
5353

54+
#pragma mark - QMUILog
55+
QMUICMI.shouldPrintDefaultLog = YES; // ShouldPrintDefaultLog : 是否允许输出 QMUILogLevelDefault 级别的 log
56+
QMUICMI.shouldPrintInfoLog = YES; // ShouldPrintInfoLog : 是否允许输出 QMUILogLevelInfo 级别的 log
57+
QMUICMI.shouldPrintWarnLog = YES; // ShouldPrintInfoLog : 是否允许输出 QMUILogLevelWarn 级别的 log
58+
QMUICMI.shouldPrintQMUIWarnLogToConsole = NO; // ShouldPrintQMUIWarnLogToConsole : 是否在出现 QMUILogWarn 时自动把这些 log 以 QMUIConsole 的方式显示到设备屏幕上
5459

5560
#pragma mark - UIControl
5661

@@ -244,11 +249,6 @@ - (void)applyConfigurationTemplate {
244249
QMUICMI.windowLevelQMUIAlertView = UIWindowLevelAlert - 4.0; // UIWindowLevelQMUIAlertView : QMUIModalPresentationViewController、QMUIPopupContainerView 里使用的 UIWindow 的 windowLevel
245250
QMUICMI.windowLevelQMUIConsole = 1; // UIWindowLevelQMUIConsole : QMUIConsole 内部的 UIWindow 的 windowLevel
246251

247-
#pragma mark - QMUILog
248-
QMUICMI.shouldPrintDefaultLog = YES; // ShouldPrintDefaultLog : 是否允许输出 QMUILogLevelDefault 级别的 log
249-
QMUICMI.shouldPrintInfoLog = YES; // ShouldPrintInfoLog : 是否允许输出 QMUILogLevelInfo 级别的 log
250-
QMUICMI.shouldPrintWarnLog = YES; // ShouldPrintInfoLog : 是否允许输出 QMUILogLevelWarn 级别的 log
251-
252252
#pragma mark - QMUIBadge
253253

254254
QMUICMI.badgeBackgroundColor = UIColorRed; // BadgeBackgroundColor : QMUIBadge 上的未读数的背景色

QMUIKit.podspec

Lines changed: 1 addition & 7 deletions
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.0"
3+
s.version = "4.4.1"
44
s.summary = "致力于提高项目 UI 开发效率的解决方案"
55
s.description = <<-DESC
66
QMUI iOS 是一个致力于提高项目 UI 开发效率的解决方案,其设计目的是用于辅助快速搭建一个具备基本设计还原效果的 iOS 项目,同时利用自身提供的丰富控件及兼容处理, 让开发者能专注于业务需求而无需耗费精力在基础代码的设计上。不管是新项目的创建,或是已有项目的维护,均可使开发效率和项目质量得到大幅度提升。
@@ -266,10 +266,6 @@ Pod::Spec.new do |s|
266266
sss.source_files = 'QMUIKit/QMUIComponents/QMUISegmentedControl.{h,m}'
267267
end
268268

269-
ss.subspec 'QMUISlider' do |sss|
270-
sss.source_files = 'QMUIKit/QMUIComponents/QMUISlider.{h,m}'
271-
end
272-
273269
ss.subspec 'QMUITableViewCell' do |sss|
274270
sss.source_files = 'QMUIKit/QMUIComponents/QMUITableViewCell.{h,m}'
275271
sss.dependency 'QMUIKit/QMUIComponents/QMUIButton'
@@ -307,7 +303,6 @@ Pod::Spec.new do |s|
307303
sss.dependency 'QMUIKit/QMUIComponents/QMUILabel'
308304
sss.dependency 'QMUIKit/QMUIComponents/QMUIPopupContainerView'
309305
sss.dependency 'QMUIKit/QMUIComponents/QMUIPopupMenuView'
310-
sss.dependency 'QMUIKit/QMUIComponents/QMUISlider'
311306
sss.dependency 'QMUIKit/QMUIComponents/QMUITextField'
312307
sss.dependency 'QMUIKit/QMUIComponents/QMUITextView'
313308
sss.dependency 'QMUIKit/QMUIComponents/QMUIToastView'
@@ -331,7 +326,6 @@ Pod::Spec.new do |s|
331326
sss.dependency 'QMUIKit/QMUIResources'
332327
sss.dependency 'QMUIKit/QMUIComponents/QMUIEmptyView'
333328
sss.dependency 'QMUIKit/QMUIComponents/QMUIButton'
334-
sss.dependency 'QMUIKit/QMUIComponents/QMUISlider'
335329
sss.dependency 'QMUIKit/QMUIComponents/QMUIPieProgressView'
336330
sss.dependency 'QMUIKit/QMUIComponents/QMUIAssetLibrary'
337331
end

QMUIKit/QMUIComponents/NavigationBarTransition/UINavigationBar+Transition.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ - (void)setQmuinb_copyStylesToBar:(UINavigationBar *)copyStylesToBar {
7676
weakContainer.object = copyStylesToBar;
7777
objc_setAssociatedObject(self, &kAssociatedObjectKey_copyStylesToBar, weakContainer, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
7878

79+
if (!copyStylesToBar) return;
80+
7981
#ifdef IOS15_SDK_ALLOWED
8082
if (@available(iOS 15.0, *)) {
8183
copyStylesToBar.standardAppearance = self.standardAppearance;

QMUIKit/QMUIComponents/NavigationBarTransition/UINavigationController+NavigationBarTransition.m

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ + (void)load {
118118
if (shouldCustomNavigationBarTransition) {
119119
disappearingViewController.qmuinb_shouldShowTransitionBar = YES;
120120
appearingViewController.qmuinb_shouldShowTransitionBar = YES;
121+
122+
// 只绑定即将显示的 vc 的 bar,注意可能在 setNavigationBarHidden: 里被覆盖,引起下述问题:
123+
// https://github.com/Tencent/QMUI_iOS/issues/1335
121124
weakNavigationController.navigationBar.qmuinb_copyStylesToBar = appearingViewController.transitionNavigationBar;
122125
}
123126
}
@@ -164,7 +167,7 @@ + (void)load {
164167
if (hidden) {
165168
[selfObject.topViewController removeTransitionNavigationBar];
166169
} else {
167-
[selfObject.topViewController addTransitionNavigationBarIfNeeded];
170+
[selfObject.topViewController addTransitionNavigationBarAndBindNavigationBar:YES];
168171
}
169172
}
170173
};
@@ -214,7 +217,7 @@ + (void)load {
214217
});
215218
}
216219

217-
- (void)addTransitionNavigationBarIfNeeded {
220+
- (void)addTransitionNavigationBarAndBindNavigationBar:(BOOL)shouldBind {
218221
// add 时虽然过滤了 navigationBarHidden 的条件,但可能在 push/pop 时,新界面暂时还没刷新导航栏的显隐状态,所以还是需要在 viewWillLayoutSubviews 那边再重新根据 navigationBarHidden 的值来决定是否隐藏假 bar
219222
if (!self.qmuinb_shouldShowTransitionBar || self.transitionNavigationBar || !self.navigationController.navigationBar || self.navigationController.navigationBarHidden) {
220223
return;
@@ -234,8 +237,10 @@ - (void)addTransitionNavigationBarIfNeeded {
234237
}
235238
#endif
236239
[self.view addSubview:customBar];
237-
customBar.originalNavigationBar = self.navigationController.navigationBar;
238-
240+
customBar.originalNavigationBar = self.navigationController.navigationBar;// 注意这里内部不会保留真 bar 和假 bar 的 copy 关系
241+
if (shouldBind) {
242+
self.navigationController.navigationBar.qmuinb_copyStylesToBar = customBar;
243+
}
239244
[self layoutTransitionNavigationBar];
240245
}
241246

@@ -561,7 +566,7 @@ - (BOOL)prefersNavigationBarBackgroundViewHidden {
561566
- (void)setQmuinb_shouldShowTransitionBar:(BOOL)shouldShowTransitionBar {
562567
objc_setAssociatedObject(self, &kAssociatedObjectKey_shouldShowTransitionBar, @(shouldShowTransitionBar), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
563568
if (shouldShowTransitionBar) {
564-
[self addTransitionNavigationBarIfNeeded];
569+
[self addTransitionNavigationBarAndBindNavigationBar:NO];// 这里不绑定 bar,因为不知道此时是两个 vc 里的哪一个
565570
self.prefersNavigationBarBackgroundViewHidden = YES;
566571
} else {
567572
[self removeTransitionNavigationBar];

QMUIKit/QMUIComponents/QMUIMarqueeLabel.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,29 @@
6565
*/
6666
- (BOOL)requestToStopAnimation;
6767
@end
68+
69+
70+
@interface UILabel (QMUI_Marquee)
71+
72+
/**
73+
是否开启系统自带的跑马灯效果(系统的只能控制开启/关闭,无法控制速度、停顿等,更多功能可以使用 @c QMUIMarqueeLabel ,但论性能还是系统的更优。
74+
75+
用法:
76+
[label qmui_startNativeMarquee];
77+
[label qmui_stopNativeMarquee]; // 当你需要停止动画时,调用这个方法(如果业务只关心什么时候开启,不关心什么时候结束,则从头到尾都可以不用调用这个方法)
78+
79+
@note 当开启该属性时,会强制把 numberOfLines 设置为1,clipsToBounds 设置为 YES。如果你是在 reuse view 内使用(例如 UITableViewCell/UICollectionViewCell),需要手动在 will display 时 start,did end display 时 stop。
80+
*/
81+
- (void)qmui_startNativeMarquee;
82+
83+
/**
84+
停止跑马灯效果,与 @c qmui_startNativeMarquee 不需要成对出现,也即如果业务不关心什么时候停止动画,可以从头到尾都不调用这个方法。
85+
*/
86+
- (void)qmui_stopNativeMarquee;
87+
88+
/**
89+
系统的跑马灯效果是否正在运行,默认为 NO。
90+
*/
91+
@property(nonatomic, assign, readonly) BOOL qmui_nativeMarqueeRunning;
92+
93+
@end

QMUIKit/QMUIComponents/QMUIMarqueeLabel.m

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,53 @@ - (BOOL)requestToStopAnimation {
266266
}
267267

268268
@end
269+
270+
@implementation UILabel (QMUI_Marquee)
271+
272+
- (void)dealloc {
273+
[self qmuimq_removeObserver];
274+
}
275+
276+
- (void)qmui_startNativeMarquee {
277+
// 系统有 _startMarqueeIfNecessary、_startMarquee,但直接开启的方法其实是 marqueeRunning
278+
BOOL running = YES;
279+
self.numberOfLines = 1;
280+
self.clipsToBounds = YES;
281+
[self qmui_performSelector:NSSelectorFromString(@"setMarqueeEnabled:") withArguments:&running, nil];
282+
[self qmui_performSelector:NSSelectorFromString(@"setMarqueeRunning:") withArguments:&running, nil];
283+
[self qmuimq_removeObserver];
284+
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(qmuimq_handleApplicationDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil];
285+
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(qmuimq_handleApplicationDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
286+
}
287+
288+
- (void)qmui_stopNativeMarquee {
289+
// 系统有 _stopMarqueeWithRedisplay:,但直接关闭的方法其实是 marqueeRunning
290+
BOOL running = NO;
291+
[self qmui_performSelector:NSSelectorFromString(@"setMarqueeRunning:") withArguments:&running, nil];
292+
[self qmui_performSelector:NSSelectorFromString(@"setMarqueeEnabled:") withArguments:&running, nil];
293+
[self qmuimq_removeObserver];
294+
}
295+
296+
- (BOOL)qmui_nativeMarqueeRunning {
297+
BOOL running = NO;
298+
[self qmui_performSelector:NSSelectorFromString(@"marqueeRunning") withPrimitiveReturnValue:&running];
299+
return running;
300+
}
301+
302+
- (void)qmuimq_handleApplicationDidEnterBackground:(NSNotification *)notification {
303+
[self qmui_bindBOOL:self.qmui_nativeMarqueeRunning forKey:@"QMUI_Marquee_Running"];
304+
}
305+
306+
- (void)qmuimq_handleApplicationDidBecomeActive:(NSNotification *)notification {
307+
if ([self qmui_getBoundBOOLForKey:@"QMUI_Marquee_Running"]) {
308+
[self qmui_stopNativeMarquee];// 要手动停止一次才能重新 start
309+
[self qmui_startNativeMarquee];
310+
}
311+
}
312+
313+
- (void)qmuimq_removeObserver {
314+
[NSNotificationCenter.defaultCenter removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];
315+
[NSNotificationCenter.defaultCenter removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil];
316+
}
317+
318+
@end

QMUIKit/QMUIComponents/QMUISlider.h

Lines changed: 0 additions & 46 deletions
This file was deleted.

QMUIKit/QMUIComponents/QMUISlider.m

Lines changed: 0 additions & 96 deletions
This file was deleted.

QMUIKit/QMUIComponents/QMUITableViewCell.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
@interface QMUITableViewCell() <UIScrollViewDelegate>
2323

24+
@property(nonatomic, assign) BOOL initByTableView;
2425
@property(nonatomic, assign, readwrite) QMUITableViewCellPosition cellPosition;
2526
@property(nonatomic, assign, readwrite) UITableViewCellStyle style;
2627
@property(nonatomic, strong) UIImageView *defaultAccessoryImageView;
@@ -32,13 +33,16 @@ @implementation QMUITableViewCell
3233

3334
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
3435
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
35-
[self didInitializeWithStyle:style];
36+
if (!self.initByTableView) {
37+
[self didInitializeWithStyle:style];
38+
}
3639
}
3740
return self;
3841
}
3942

4043
- (instancetype)initForTableView:(UITableView *)tableView withStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
41-
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
44+
self.initByTableView = YES;
45+
if (self = [self initWithStyle:style reuseIdentifier:reuseIdentifier]) {// 这里需要调用 self 的 initWithStyle,而不是 super,目的是为了让业务在重写 init 方法时可以沿用系统默认的思路,去重写 initWithStyle:reuseIdentifier:,但在 vc 里使用 cell 时又可以直接调用 initForTableView:withStyle:。
4246
self.parentTableView = tableView;
4347
[self didInitializeWithStyle:style];// 因为设置了 parentTableView,样式可能都需要变,所以这里重新执行一次 didInitializeWithStyle: 里的 qmui_styledAsQMUITableViewCell
4448
}
@@ -303,6 +307,7 @@ - (void)handleAccessoryButtonEvent:(QMUIButton *)detailButton {
303307
@implementation QMUITableViewCell(QMUISubclassingHooks)
304308

305309
- (void)didInitializeWithStyle:(UITableViewCellStyle)style {
310+
self.initByTableView = NO;
306311
_cellPosition = QMUITableViewCellPositionNone;
307312

308313
_style = style;

0 commit comments

Comments
 (0)