4.2.0
由于 iOS 14 Beta 的发布,QMUI 从这个版本开始将不再支持 iOS 9。
新增功能
- 增加
QMUITableViewStyleInsetGrouped
组件用于支持全 iOS 版本的 InsetGrouped 类型的列表,示例代码请查看 QMUI Demo→QMUIKit→QMUITableView→QMUITableViewStyleInsetGrouped。 - 配置表增加
TableViewGroupedSeparatorColor
用于控制UITableViewStyleGrouped
类型的列表分隔线颜色。 - #1015
QMUIAlertController
增加alertTextFieldTextInsets
、alertTextFieldMarginBlock
属性用于调整输入框的大小和布局。 QMUIPopupContainerView
增加arrowImage
属性支持用一张图来作为浮层的箭头。QMUIStaticTableViewCellData
增加didSelectBlock
,支持以 block 的形式处理 cell 点击事件(以前只能使用 target-action 模式);增加accessoryBlock
,支持以 block 的形式处理accessoryView
点击事件(以前只能使用 target-action 模式)。UIColor(QMUI)
增加qmui_colorWithRGBAString:
方法用于将一个 RGBA 字符串转换成UIColor
对象。UIView(QMUI)
增加qmui_sizeThatFitsBlock
属性便于重写sizeThatFits:
。- 增加
UIVisualEffectView(QMUI)
组件,提供qmui_foregroundColor
属性让你可以去掉系统自带的前景色的同时设置自己的前景色,从而保证更准确的设计效果。系统的UIVisualEffectView
在不同的 style 下会带有不同的前景色。 UITableView(QMUI)
增加qmui_validContentWidth
属性用于获取当前列表用于呈现内容的区域的宽度,例如全面屏设备下会减去 safeAreaInsets.left/right,InsetGrouped 样式下会减去左右的缩进。UITableViewCell(QMUI)
增加以下特性:- 增加
qmui_style
属性用于获取初始化 cell 时指定的UITableViewCellStyle
。 - 增加
qmui_cellPosition
属性用于在willDisplayCell
及以后的时机里能获取当前 cell 在 section 里的位置,如果是在cellForRow
里则依然只能自己通过-[UITableView qmui_positionForRowAtIndexPath:]
计算,无法使用qmui_cellPosition
。 - 增加
qmui_separatorInsetsBlock
、qmui_topSeparatorInsetsBlock
用于控制 cell 的分隔线位置,由于 block 是渲染时才会调用,所以你可以在 block 里方便地根据当前 tableView 的 style、cell 的 position、cell 的 subviews 的布局来设置分隔线位置,这是系统自带的分隔线无法做到的事情。你可以在业务项目里 swizzleUITableViewCell
的 init 方法,在里面统一设置全局分隔线的逻辑,就无需每个 cell 子类都调整一次。
- 增加
UISearchBar(QMUI)
增加以下特性,对应地 QMUI Demo 也增加新的示例界面:QMUIKit→UISearchBar+QMUI→UISearchBar(QMUI)
- 增加
qmui_centerPlaceholder
用于让 iOS 11 及以后的搜索框 placeholder 也能默认居中(系统默认是居左)。 - 增加
qmui_leftAccessoryView
、qmui_rightAccessoryView
支持在输入框左右各显示一个 view,从而你可以方便地添加自己的按钮(例如在搜索框左边显示一个返回按钮,在右边显示一个结果过滤、结果排序按钮等)。
- 增加
QMUIHelper
增加executeBlock: oncePerIdentifier:
用于令某段逻辑只被执行一次,QMUIKit 中通常用来避免重复 swizzle 相同方法。QMUICommonDefines.h
增加IOS14_SDK_ALLOWED
用于识别当前是 iOS 14 SDK 编译环境。- 让
UINavigationBar
、UITabBar
在没设置backgroundImage
时也能正确显示shadowImage
(系统默认行为是只有设置了backgroundImage
后shadowImage
才能生效),从而保证不同 iOS 系统里的表现一致。 - 感谢 @MaxwellLeeee 增加对
QMUIToastAnimator
里 Zoom 和 Slide 两种动画方式的支持。
会带来 QMUI 新旧版本兼容问题的更新
- 最低支持版本从 iOS 9.0 升级为 iOS 10.0。
- 重构
QMUIBadge
未读数组件,原本仅支持在UIBarItem
上显示未读数/未读红点,现在可以在任意的UIView
上显示未读数/未读红点了。同时为了优化使用体验,将原本基于中心布局的qmui_badgeCenterOffset
、qmui_badgeCenterOffsetLandscape
、qmui_updatesIndicatorCenterOffset
、qmui_updatesIndicatorCenterOffsetLandscape
4个属性标记为废弃,新组件将基于右上角布局,使用新属性qmui_badgeOffset
、qmui_badgeOffsetLandscape
、qmui_updatesIndicatorOffset
、qmui_updatesIndicatorOffsetLandscape
代替以前的4个旧属性。同时 QMUI Demo 里也增加了对应的示例代码。 - 对于
UITableView
,如果开启了配置表并且将TableViewEstimatedHeightEnabled
置为NO
,则在 4.2.0 里会在初始化时把tableView.rowHeight
修改为TableViewCellNormalHeight
,而在 4.2.0 以前,不管是否使用配置表,不管TableViewEstimatedHeightEnabled
的值多少,在 tableView 初始化时rowHeight
会保持系统默认(UITableViewAutomaticDimension
)。这可能会让使用了 self-sizing 的UITableView
cell 高度错误,无法自动计算。遇到这种情况,请考虑将配置表里的TableViewCellNormalHeight
改为UITableViewAutomaticDimension
,或者仅修改出问题的业务界面的tableView.rowHeight = UITableViewAutomaticDimension;
。
如何适配新版
- 全局搜索“qmui_badgeCenterOffset”,改为用
qmui_badgeOffset
,具体值要自行调整。 - 全局搜索“qmui_badgeCenterOffsetLandscape”,改为用
qmui_badgeOffsetLandscape
,具体值要自行调整。 - 全局搜索“qmui_updatesIndicatorCenterOffset”,改为用
qmui_updatesIndicatorOffset
,具体值要自行调整。 - 全局搜索“qmui_updatesIndicatorCenterOffsetLandscape”,改为用
qmui_updatesIndicatorOffsetLandscape
,具体值要自行调整。 - 全局搜索“BadgeCenterOffset”,改为用
BadgeOffset
。 - 全局搜索“BadgeCenterOffsetLandscape”,改为用
BadgeOffsetLandscape
。 - 全局搜索“UpdatesIndicatorCenterOffset”,改为用
UpdatesIndicatorOffset
。 - 全局搜索“UpdatesIndicatorCenterOffsetLandscape”,改为用
UpdatesIndicatorOffsetLandscape
。 - 全局搜索对
QMUIAlertController.dismissKeyboardAutomatically
的使用,由于不支持 iOS 9,所以这个属性已经没用了,请删除。
如果有使用配置表
- 将以下代码添加到配置表里:
QMUICMI.badgeOffset = CGPointMake(-9, 11); // BadgeOffset : QMUIBadge 上的未读数相对于目标 view 右上角的偏移
QMUICMI.badgeOffsetLandscape = CGPointMake(-9, 6); // BadgeOffsetLandscape : QMUIBadge 上的未读数在横屏下相对于目标 view 右上角的偏移
QMUICMI.updatesIndicatorOffset = CGPointMake(4, UpdatesIndicatorSize.height); // UpdatesIndicatorOffset : QMUIBadge 未读红点相对于目标 view 右上角的偏移
QMUICMI.updatesIndicatorOffsetLandscape = UpdatesIndicatorOffset; // UpdatesIndicatorOffsetLandscape : QMUIBadge 未读红点在横屏下相对于目标 view 右上角的偏移
QMUICMI.tableViewGroupedSeparatorColor = TableViewSeparatorColor; // TableViewGroupedSeparatorColor : Grouped 类型的 QMUITableView 分隔线颜色
#pragma mark - InsetGrouped TableView
QMUICMI.tableViewInsetGroupedCornerRadius = 10; // TableViewInsetGroupedCornerRadius : InsetGrouped 类型的 UITableView 内 cell 的圆角值
QMUICMI.tableViewInsetGroupedHorizontalInset = PreferredValueForVisualDevice(20, 15); // TableViewInsetGroupedHorizontalInset: InsetGrouped 类型的 UITableView 内的左右缩进值
QMUICMI.tableViewInsetGroupedBackgroundColor = TableViewGroupedBackgroundColor; // TableViewInsetGroupedBackgroundColor : InsetGrouped 类型的 UITableView 的背景色
QMUICMI.tableViewInsetGroupedSeparatorColor = TableViewGroupedSeparatorColor; // TableViewInsetGroupedSeparatorColor : InsetGrouped 类型的 QMUITableView 分隔线颜色
QMUICMI.tableViewInsetGroupedCellTitleLabelColor = TableViewGroupedCellTitleLabelColor; // TableViewInsetGroupedCellTitleLabelColor : InsetGrouped 类型的 QMUITableView cell 里的标题颜色
QMUICMI.tableViewInsetGroupedCellDetailLabelColor = TableViewGroupedCellDetailLabelColor; // TableViewInsetGroupedCellDetailLabelColor : InsetGrouped 类型的 QMUITableView cell 里的副标题颜色
QMUICMI.tableViewInsetGroupedCellBackgroundColor = TableViewGroupedCellBackgroundColor; // TableViewInsetGroupedCellBackgroundColor : InsetGrouped 类型的 QMUITableView cell 背景色
QMUICMI.tableViewInsetGroupedCellSelectedBackgroundColor = TableViewGroupedCellSelectedBackgroundColor; // TableViewInsetGroupedCellSelectedBackgroundColor : InsetGrouped 类型的 QMUITableView cell 点击时的背景色
QMUICMI.tableViewInsetGroupedCellWarningBackgroundColor = TableViewGroupedCellWarningBackgroundColor; // TableViewInsetGroupedCellWarningBackgroundColor : InsetGrouped 类型的 QMUITableView cell 在提醒状态下的背景色
QMUICMI.tableViewInsetGroupedSectionHeaderFont = TableViewGroupedSectionHeaderFont; // TableViewInsetGroupedSectionHeaderFont : InsetGrouped 类型的 QMUITableView sectionHeader 里的文字字体
QMUICMI.tableViewInsetGroupedSectionFooterFont = TableViewInsetGroupedSectionHeaderFont; // TableViewInsetGroupedSectionFooterFont : InsetGrouped 类型的 QMUITableView sectionFooter 里的文字字体
QMUICMI.tableViewInsetGroupedSectionHeaderTextColor = TableViewGroupedSectionHeaderTextColor; // TableViewInsetGroupedSectionHeaderTextColor : InsetGrouped 类型的 QMUITableView sectionHeader 里的文字颜色
QMUICMI.tableViewInsetGroupedSectionFooterTextColor = TableViewInsetGroupedSectionHeaderTextColor; // TableViewInsetGroupedSectionFooterTextColor : InsetGrouped 类型的 QMUITableView sectionFooter 里的文字颜色
QMUICMI.tableViewInsetGroupedSectionHeaderAccessoryMargins = TableViewGroupedSectionHeaderAccessoryMargins; // TableViewInsetGroupedSectionHeaderAccessoryMargins : InsetGrouped 类型的 QMUITableView sectionHeader accessoryView 的间距
QMUICMI.tableViewInsetGroupedSectionFooterAccessoryMargins = TableViewInsetGroupedSectionHeaderAccessoryMargins; // TableViewInsetGroupedSectionFooterAccessoryMargins : InsetGrouped 类型的 QMUITableView sectionFooter accessoryView 的间距
QMUICMI.tableViewInsetGroupedSectionHeaderDefaultHeight = TableViewGroupedSectionHeaderDefaultHeight; // TableViewInsetGroupedSectionHeaderDefaultHeight : InsetGrouped 类型的 QMUITableView sectionHeader 的默认高度(也即没使用自定义的 sectionHeaderView 时的高度),注意如果不需要间距,请用 CGFLOAT_MIN
QMUICMI.tableViewInsetGroupedSectionFooterDefaultHeight = TableViewGroupedSectionFooterDefaultHeight; // TableViewInsetGroupedSectionFooterDefaultHeight : InsetGrouped 类型的 QMUITableView sectionFooter 的默认高度(也即没使用自定义的 sectionFooterView 时的高度),注意如果不需要间距,请用 CGFLOAT_MIN
QMUICMI.tableViewInsetGroupedSectionHeaderContentInset = TableViewGroupedSectionHeaderContentInset; // TableViewInsetGroupedSectionHeaderContentInset : InsetGrouped 类型的 QMUITableView sectionHeader 里的内容的 padding
QMUICMI.tableViewInsetGroupedSectionFooterContentInset = TableViewInsetGroupedSectionHeaderContentInset; // TableViewInsetGroupedSectionFooterContentInset : InsetGrouped 类型的 QMUITableView sectionFooter 里的内容的 padding
- 将以下设置项从配置表里删除:
QMUICMI.badgeCenterOffset = CGPointMake(14, -10); // BadgeCenterOffset : QMUIBadge 未读数相对于目标 view 中心的偏移
QMUICMI.badgeCenterOffsetLandscape = CGPointMake(16, -7); // BadgeCenterOffsetLandscape : QMUIBadge 未读数在横屏下相对于目标 view 中心的偏移
QMUICMI.updatesIndicatorCenterOffset = CGPointMake(14, -10); // UpdatesIndicatorCenterOffset : QMUIBadge 未读红点相对于目标 view 中心的偏移
QMUICMI.updatesIndicatorCenterOffsetLandscape = CGPointMake(14, -10); // UpdatesIndicatorCenterOffsetLandscape : QMUIBadge 未读红点在横屏下相对于目标 view 中心点的偏移
Bugfix
- #997 修复输入框聚焦并升起键盘的情况下,App 进入后台再回到前台,键盘外观会错误的 bug。
- #1001 修复在 Mac Catalyst 里调用
+[UIImage qmui_imageWithThemeProvider]
会死循环的 bug。 - #1012 修复
QMUIPopupMenuButtonItem
内的QMUIButton.imageView
可能出现负值的bounds
,导致一些布局错误的 bug。 - #1026 修复 iOS 12 及以下,
UITabBarItem
只设置image
没设置selectedImage
时,无法通过配置表设置图片颜色的 bug。 - #1037 修复
QMUIToast
修改内容后布局没有刷新的 bug。 - #1042 修复 iOS 14 下切换到 emoji 键盘会 crash 的 bug。
- #1048 修复 `-[QMUIZoomImageView showEmptyViewWithText] 无法显示 emptyView 的 bug。
- #1051 修复
QMUIButton
搭配 Autolayout 使用时可能出现的文字布局错误的 bug。 - #1061 修复 CocoaPods Spec 文件里对 Photos.framework 的依赖写法,改为在 Subspec 内依赖,避免引入其他子模块时也错误地引入了 Photos.framework。
- #1063 修复 iOS 14 下当关闭 NeedsBackBarButtonItemTitle 后,长按返回按钮出现的快速返回菜单里无法显示标题的 bug。
- 修复 iOS 14 下修改了
UISearchBar
字体后会导致 searchBar 内的输入框高度错误的 bug。 - 修复 iOS 12 及以下
UITextField(QMUI).qmui_clearButtonImage
无效的 bug。 - 修复
QMUINavigationTitlteView
在 vertical 布局模式下,如果 subtitle 比 title 长的话可以看到 loading 和 accessoryView 与 title 之间间距过大的 bug。 - 修复
QMUINavigationTitleView
文字长度过长时没有截断的 bug。 - 修复使用
QMUINavigationButton
作为自定义返回按钮时,在 iOS 13.4.1 系统新增的 Full Keyboard Access 模式下无法使用快捷键 Tab+B 返回上一级界面的 bug。 - 修复
QMUIAppearance
无法在非UIView
、UIViewController
对象里使用的 bug。 - 修复
-[UIImage (QMUI) qmui_imageWithTintColor:]
对opaque
的image
效果错误的 bug。 - 修复
+[QMUIHelper compareSystemVersion:toVersion:]
返回结果相反的 bug。 - 修复
NSString(QMUI)
里qmui_substringAvoidBreakingUpCharacterSequencesFromIndex:lessValue:countingNonASCIICharacterAsTwo:
、qmui_substringAvoidBreakingUpCharacterSequencesToIndex:lessValue:countingNonASCIICharacterAsTwo:
裁剪不准确的 bug。 - 修复以下几个类的类方法里初始化实例的错误写法,导致如果是子类通过类方法得到的依然是父类的实例的 bug。
- QMUIAlertAction
- QMUIDisplayLinkAnimation
- QMUILogItem
- QMUIConsoleLogItem
- QMUIEmotion
- QMUIMoreOperationItemView
- QMUIMultipleDelegates
- QMUIPopupMenuButtonItem
- QMUIStaticTableViewCellData
- QMUIPropertyDescriptor
- UIBarButtonItem(QMUINavigatiaonButton)
- UIColor(QMUITheme)
- NSMutableParagraphStyle(QMUI)
其他
- 将原本属于
UIControl(QMUI)
的qmui_outsideEdge
属性迁移到UIView(QMUI)
,使其适用于更多场景。 - 优化
QMUIModalPresentationViewController
在键盘位置发生变化时刷新布局的频率。 - 优化
QMUICommonTableViewController
手势返回过程中当前 selected 的那个 cell 的背景色可以跟随手势进度慢慢消失。 - 将
QMUICommonTableViewController
里原本监听contentInset
的 KVO 主体改为一个独立的对象,避免QMUICommonTableViewController
的子类重写observeValueForKeyPath:ofObject:change:context:
时不知道要调用 super 的问题。 - 去掉
-[CALayer(QMUI) qmui_sendSublayerToBack:]
、-[CALayer(QMUI) qmui_bringSublayerToFront:]
里对参数是否属于当前 layer 的 sublayers 的判断,使这两个方法更通用。 - 感谢 @kimwjc 优化对 UIAccessibility 无障碍访问的支持。