Skip to content

Commit

Permalink
4.6.1 - 最低支持版本上升到 iOS 13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
molicechen committed Dec 7, 2022
1 parent 0fa7d9e commit 54dc8d0
Show file tree
Hide file tree
Showing 49 changed files with 738 additions and 1,586 deletions.
9 changes: 3 additions & 6 deletions QMUIConfigurationTemplate/QMUIConfigurationTemplate.m
Original file line number Diff line number Diff line change
Expand Up @@ -276,21 +276,18 @@ - (void)applyConfigurationTemplate {
QMUICMI.automaticCustomNavigationBarTransitionStyle = NO; // AutomaticCustomNavigationBarTransitionStyle : 界面 push/pop 时是否要自动根据两个界面的 barTintColor/backgroundImage/shadowImage 的样式差异来决定是否使用自定义的导航栏效果
QMUICMI.supportedOrientationMask = UIInterfaceOrientationMaskAll; // SupportedOrientationMask : 默认支持的横竖屏方向
QMUICMI.automaticallyRotateDeviceOrientation = NO; // AutomaticallyRotateDeviceOrientation : 是否在界面切换或 viewController.supportedOrientationMask 发生变化时自动旋转屏幕(仅 iOS 15 及以前版本需要,iOS 16 系统会自动处理,该开关无意义。)
QMUICMI.defaultStatusBarStyle = UIStatusBarStyleDefault; // DefaultStatusBarStyle : 默认的状态栏样式,默认值为 UIStatusBarStyleDefault,也即在 iOS 12 及以前是黑色文字,iOS 13 及以后会自动根据当前 App 是否处于 Dark Mode 切换颜色。如果你希望固定为白色,请设置为 UIStatusBarStyleLightContent,固定黑色则设置为 QMUIStatusBarStyleDarkContent
QMUICMI.defaultStatusBarStyle = UIStatusBarStyleDefault; // DefaultStatusBarStyle : 默认的状态栏样式,默认值为 UIStatusBarStyleDefault,也即在 iOS 12 及以前是黑色文字,iOS 13 及以后会自动根据当前 App 是否处于 Dark Mode 切换颜色。如果你希望固定为白色,请设置为 UIStatusBarStyleLightContent,固定黑色则设置为 UIStatusBarStyleDarkContent
QMUICMI.needsBackBarButtonItemTitle = YES; // NeedsBackBarButtonItemTitle : 全局是否需要返回按钮的 title,不需要则只显示一个返回image
QMUICMI.hidesBottomBarWhenPushedInitially = NO; // HidesBottomBarWhenPushedInitially : QMUICommonViewController.hidesBottomBarWhenPushed 的初始值,默认为 NO,以保持与系统默认值一致,但通常建议改为 YES,因为一般只有 tabBar 首页那几个界面要求为 NO
QMUICMI.preventConcurrentNavigationControllerTransitions = YES; // PreventConcurrentNavigationControllerTransitions : 自动保护 QMUINavigationController 在上一次 push/pop 尚未结束的时候就进行下一次 push/pop 的行为,避免产生 crash
QMUICMI.navigationBarHiddenInitially = NO; // NavigationBarHiddenInitially : QMUINavigationControllerDelegate preferredNavigationBarHidden 的初始值,默认为NO
QMUICMI.shouldFixTabBarTransitionBugInIPhoneX = NO; // ShouldFixTabBarTransitionBugInIPhoneX : 是否需要自动修复 iOS 11 下,iPhone X 的设备在 push 界面时,tabBar 会瞬间往上跳的 bug
QMUICMI.shouldFixTabBarSafeAreaInsetsBug = NO; // ShouldFixTabBarSafeAreaInsetsBug : 是否要对 iOS 11 及以后的版本修复当存在 UITabBar 时,UIScrollView 的 inset.bottom 可能错误的 bug(issue #218 #934),默认为 YES
QMUICMI.shouldFixSearchBarMaskViewLayoutBug = NO; // ShouldFixSearchBarMaskViewLayoutBug : 是否自动修复 UISearchController.searchBar 被当作 tableHeaderView 使用时可能出现的布局 bug(issue #950)
QMUICMI.shouldPrintQMUIWarnLogToConsole = IS_DEBUG; // ShouldPrintQMUIWarnLogToConsole : 是否在出现 QMUILogWarn 时自动把这些 log 以 QMUIConsole 的方式显示到设备屏幕上
QMUICMI.sendAnalyticsToQMUITeam = YES; // SendAnalyticsToQMUITeam : 是否允许在 DEBUG 模式下上报 Bundle Identifier 和 Display Name 给 QMUI 统计用
QMUICMI.dynamicPreferredValueForIPad = NO; // DynamicPreferredValueForIPad : 当 iPad 处于 Slide Over 或 Split View 分屏模式下,宏 `PreferredValueForXXX` 是否把 iPad 视为某种屏幕宽度近似的 iPhone 来取值。
if (@available(iOS 13.0, *)) {
QMUICMI.ignoreKVCAccessProhibited = NO; // IgnoreKVCAccessProhibited : 是否全局忽略 iOS 13 对 KVC 访问 UIKit 私有属性的限制
QMUICMI.adjustScrollIndicatorInsetsByContentInsetAdjustment = NO; // AdjustScrollIndicatorInsetsByContentInsetAdjustment : 当将 UIScrollView.contentInsetAdjustmentBehavior 设为 UIScrollViewContentInsetAdjustmentNever 时,是否自动将 UIScrollView.automaticallyAdjustsScrollIndicatorInsets 设为 NO,以保证原本在 iOS 12 下的代码不用修改就能在 iOS 13 下正常控制滚动条的位置。
}
QMUICMI.ignoreKVCAccessProhibited = NO; // IgnoreKVCAccessProhibited : 是否全局忽略 iOS 13 对 KVC 访问 UIKit 私有属性的限制
QMUICMI.adjustScrollIndicatorInsetsByContentInsetAdjustment = NO; // AdjustScrollIndicatorInsetsByContentInsetAdjustment : 当将 UIScrollView.contentInsetAdjustmentBehavior 设为 UIScrollViewContentInsetAdjustmentNever 时,是否自动将 UIScrollView.automaticallyAdjustsScrollIndicatorInsets 设为 NO,以保证原本在 iOS 12 下的代码不用修改就能在 iOS 13 下正常控制滚动条的位置。
}

// QMUI 2.3.0 版本里,配置表新增这个方法,返回 YES 表示在 App 启动时要自动应用这份配置表。仅当你的 App 里存在多份配置表时,才需要把除默认配置表之外的其他配置表的返回值改为 NO。
Expand Down
4 changes: 2 additions & 2 deletions 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.6.0"
s.version = "4.6.1"
s.summary = "致力于提高项目 UI 开发效率的解决方案"
s.description = <<-DESC
QMUI iOS 是一个致力于提高项目 UI 开发效率的解决方案,其设计目的是用于辅助快速搭建一个具备基本设计还原效果的 iOS 项目,同时利用自身提供的丰富控件及兼容处理, 让开发者能专注于业务需求而无需耗费精力在基础代码的设计上。不管是新项目的创建,或是已有项目的维护,均可使开发效率和项目质量得到大幅度提升。
Expand All @@ -15,7 +15,7 @@ Pod::Spec.new do |s|
s.documentation_url = 'https://qmuiteam.com/ios/page/document.html'
s.screenshot = 'https://cloud.githubusercontent.com/assets/1190261/26751376/63f96538-486a-11e7-81cf-5bc83a945207.png'

s.platform = :ios, '11.0'
s.platform = :ios, '13.0'
s.frameworks = 'Foundation', 'UIKit', 'CoreGraphics'
s.preserve_paths = 'QMUIConfigurationTemplate/*'
s.source_files = 'QMUIKit/QMUIKit.h'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,6 @@ + (void)load {
weakNavigationController.navigationBar.qmuinb_copyStylesToBar = nil;
}
break;
case QMUINavigationActionDidPop: {

if (@available(iOS 13.0, *)) {
} else {
// iOS 12 及以下系统,在不使用自定义 titleView 的情况下,在 viewWillAppear 时通过修改 navigationBar.titleTextAttributes 来设置新界面的导航栏标题样式,push 时是生效的,但 pop 时右边界面的样式会覆盖左边界面的样式,所以 pop 时的 titleTextAttributes 改为在 did pop 时处理
// 如果用自定义 titleView 则没这种问题,只是为了代码简单,时机的选择不区分是否自定义 title
[appearingViewController renderNavigationBarTitleAppearanceAnimated:animated];
[weakNavigationController qmui_animateAlongsideTransition:nil completion:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
// 这里要重新获取 topViewController,因为触发 pop 有两种:1. 普通完整的 pop;2.手势返回又取消。后者在 completion 里拿到的 topViewController 已经不是 completion 外面那个 appearingViewController 了,只有重新获取的 topViewController 才能代表最终可视的那个界面
// https://github.com/Tencent/QMUI_iOS/issues/1210
[weakNavigationController.topViewController renderNavigationBarTitleAppearanceAnimated:animated];
}];
}
}
break;

default:
break;
}
Expand Down Expand Up @@ -404,16 +388,7 @@ - (void)renderNavigationBarAppearanceAnimated:(BOOL)animated {
// iOS 13 及以上,title 的更新只在 viewWillAppear 这里进行就可以了,但 iOS 12 及以下还要靠 popViewController 那边
// iOS 12 及以下系统,在不使用自定义 titleView 的情况下,在 viewWillAppear 时通过修改 navigationBar.titleTextAttributes 来设置新界面的导航栏标题样式,push 时是生效的,但 pop 时右边界面的样式会覆盖左边界面的样式,所以 pop 时的 titleTextAttributes 改为在 did pop 时处理
// 如果用自定义 titleView 则没这种问题,只是为了代码简单,时机的选择不区分是否自定义 title
BOOL shouldRenderTitle = YES;
if (@available(iOS 13.0, *)) {
} else {
// push/pop 时如果 animated 为 NO,那么走到这里时 push/pop 已经结束了,action 处于 unknown 状态,所以这里要把 unknown 也包含进去
// https://github.com/Tencent/QMUI_iOS/issues/1190
shouldRenderTitle = navigationController.qmui_navigationAction >= QMUINavigationActionUnknow && navigationController.qmui_navigationAction <= QMUINavigationActionPushCompleted;
}
if (shouldRenderTitle) {
[vc renderNavigationBarTitleAppearanceAnimated:animated];
}
[vc renderNavigationBarTitleAppearanceAnimated:animated];
}

// 仅处理导航栏标题
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,7 @@ - (BOOL)prefersStatusBarHidden {
if (self.qmui_visibleState < QMUIViewControllerDidAppear || self.qmui_visibleState >= QMUIViewControllerDidDisappear) {
// 在 present/dismiss 动画过程中,都使用原界面的状态栏显隐状态
if (self.presentingViewController) {
BOOL statusBarHidden = NO;
if (@available(iOS 13.0, *)) {
statusBarHidden = self.presentingViewController.view.window.windowScene.statusBarManager.statusBarHidden;
} else {
statusBarHidden = UIApplication.sharedApplication.statusBarHidden;
}
BOOL statusBarHidden = self.presentingViewController.view.window.windowScene.statusBarManager.statusBarHidden;
self.originalStatusBarHidden = statusBarHidden;
return self.originalStatusBarHidden;
}
Expand Down
14 changes: 6 additions & 8 deletions QMUIKit/QMUIComponents/QMUIKeyboardManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,12 @@ - (void)setNotification:(NSNotification *)notification {
CGRect beginFrame = [[self.originUserInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue];
CGRect endFrame = [[self.originUserInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];

if (@available(iOS 13.0, *)) {
// iOS 13 分屏键盘 x 不是 0,不知道是系统 BUG 还是故意这样,先这样保护,再观察一下后面的 beta 版本
if (IS_SPLIT_SCREEN_IPAD && beginFrame.origin.x > 0) {
beginFrame.origin.x = 0;
}
if (IS_SPLIT_SCREEN_IPAD && endFrame.origin.x > 0) {
endFrame.origin.x = 0;
}
// iOS 13 分屏键盘 x 不是 0,不知道是系统 BUG 还是故意这样,先这样保护,再观察一下后面的 beta 版本
if (IS_SPLIT_SCREEN_IPAD && beginFrame.origin.x > 0) {
beginFrame.origin.x = 0;
}
if (IS_SPLIT_SCREEN_IPAD && endFrame.origin.x > 0) {
endFrame.origin.x = 0;
}

_beginFrame = beginFrame;
Expand Down
2 changes: 1 addition & 1 deletion QMUIKit/QMUIComponents/QMUILogManagerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ - (void)initTableView {
- (void)initSearchController {
[super initSearchController];
self.searchController.qmui_preferredStatusBarStyleBlock = ^UIStatusBarStyle{
return QMUIStatusBarStyleDarkContent;
return UIStatusBarStyleDarkContent;
};
}

Expand Down
17 changes: 0 additions & 17 deletions QMUIKit/QMUIComponents/QMUIModalPresentationViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -805,23 +805,6 @@ + (BOOL)hideAllVisibleModalPresentationViewControllerIfCan {

@implementation QMUIModalPresentationWindow

- (void)layoutSubviews {
[super layoutSubviews];
// 避免来电状态时只 modal 的遮罩只盖住一部分的状态栏
// 但在 iOS 13 及以后,来电状态下状态栏的高度不会再变化了
// https://github.com/Tencent/QMUI_iOS/issues/375
if (@available(iOS 13.0, *)) {
} else {
if (self.rootViewController) {
UIView *rootView = self.rootViewController.view;
if (CGRectGetMinY(rootView.frame) > 0 && !UIApplication.sharedApplication.statusBarHidden && StatusBarHeight > CGRectGetMinY(rootView.frame)) {
rootView.frame = self.bounds;
}
}
}

}

@end

@implementation UIViewController (QMUIModalPresentationViewController)
Expand Down
2 changes: 1 addition & 1 deletion QMUIKit/QMUIComponents/QMUISearchController.m
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ - (BOOL)shouldShowSearchBar {

- (void)initSearchController {
if ([self isViewLoaded] && self.shouldShowSearchBar && !self.searchController) {
self.searchController = [[QMUISearchController alloc] initWithContentsViewController:self resultsTableViewStyle:self.tableView.qmui_style];
self.searchController = [[QMUISearchController alloc] initWithContentsViewController:self resultsTableViewStyle:self.tableView.style];
self.searchController.searchResultsDelegate = self;
self.searchController.searchBar.placeholder = @"搜索";
self.searchController.searchBar.qmui_usedAsTableHeaderView = YES;// 以 tableHeaderView 的方式使用 searchBar 的话,将其置为 YES,以辅助兼容一些系统 bug
Expand Down
2 changes: 1 addition & 1 deletion QMUIKit/QMUIComponents/QMUITableViewHeaderFooterView.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ - (UIColor *)backgroundColor {
- (void)updateAppearance {
if (!QMUICMIActivated || (!self.parentTableView && !self.qmui_tableView) || self.type == QMUITableViewHeaderFooterViewTypeUnknow) return;

UITableViewStyle style = (self.parentTableView ?: self.qmui_tableView).qmui_style;
UITableViewStyle style = (self.parentTableView ?: self.qmui_tableView).style;

if (self.type == QMUITableViewHeaderFooterViewTypeHeader) {
self.titleLabel.font = PreferredValueForTableViewStyle(style, TableViewSectionHeaderFont, TableViewGroupedSectionHeaderFont, TableViewInsetGroupedSectionHeaderFont);
Expand Down
16 changes: 5 additions & 11 deletions QMUIKit/QMUIComponents/QMUITheme/QMUIThemeManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,22 @@ - (instancetype)initWithName:(__kindof NSObject<NSCopying> *)name {
_name = name;
self._themeIdentifiers = NSMutableArray.new;
self._themes = NSMutableArray.new;
if (@available(iOS 13.0, *)) {
[UITraitCollection qmui_addUserInterfaceStyleWillChangeObserver:self selector:@selector(handleUserInterfaceStyleWillChangeEvent:)];
}
[UITraitCollection qmui_addUserInterfaceStyleWillChangeObserver:self selector:@selector(handleUserInterfaceStyleWillChangeEvent:)];
}
return self;
}

- (void)handleUserInterfaceStyleWillChangeEvent:(UITraitCollection *)traitCollection {
if (!_respondsSystemStyleAutomatically) return;
if (@available(iOS 13.0, *)) {
if (traitCollection && self.identifierForTrait) {
self.currentThemeIdentifier = self.identifierForTrait(traitCollection);
}
if (traitCollection && self.identifierForTrait) {
self.currentThemeIdentifier = self.identifierForTrait(traitCollection);
}
}

- (void)setRespondsSystemStyleAutomatically:(BOOL)respondsSystemStyleAutomatically {
_respondsSystemStyleAutomatically = respondsSystemStyleAutomatically;
if (@available(iOS 13.0, *)) {
if (_respondsSystemStyleAutomatically && self.identifierForTrait) {
self.currentThemeIdentifier = self.identifierForTrait([UITraitCollection currentTraitCollection]);
}
if (_respondsSystemStyleAutomatically && self.identifierForTrait) {
self.currentThemeIdentifier = self.identifierForTrait([UITraitCollection currentTraitCollection]);
}
}

Expand Down
Loading

0 comments on commit 54dc8d0

Please sign in to comment.