Skip to content

4.2.0

Compare
Choose a tag to compare
@MoLice MoLice released this 29 Jul 16:20
· 75 commits to master since this release

由于 iOS 14 Beta 的发布,QMUI 从这个版本开始将不再支持 iOS 9

新增功能

  1. 增加 QMUITableViewStyleInsetGrouped 组件用于支持全 iOS 版本的 InsetGrouped 类型的列表,示例代码请查看 QMUI Demo→QMUIKit→QMUITableView→QMUITableViewStyleInsetGrouped。
  2. 配置表增加 TableViewGroupedSeparatorColor 用于控制 UITableViewStyleGrouped 类型的列表分隔线颜色。
  3. #1015 QMUIAlertController 增加 alertTextFieldTextInsetsalertTextFieldMarginBlock 属性用于调整输入框的大小和布局。
  4. QMUIPopupContainerView 增加 arrowImage 属性支持用一张图来作为浮层的箭头。
  5. QMUIStaticTableViewCellData 增加 didSelectBlock,支持以 block 的形式处理 cell 点击事件(以前只能使用 target-action 模式);增加 accessoryBlock,支持以 block 的形式处理 accessoryView 点击事件(以前只能使用 target-action 模式)。
  6. UIColor(QMUI) 增加 qmui_colorWithRGBAString: 方法用于将一个 RGBA 字符串转换成 UIColor 对象。
  7. UIView(QMUI) 增加 qmui_sizeThatFitsBlock 属性便于重写 sizeThatFits:
  8. 增加 UIVisualEffectView(QMUI) 组件,提供 qmui_foregroundColor 属性让你可以去掉系统自带的前景色的同时设置自己的前景色,从而保证更准确的设计效果。系统的 UIVisualEffectView 在不同的 style 下会带有不同的前景色。
  9. UITableView(QMUI) 增加 qmui_validContentWidth 属性用于获取当前列表用于呈现内容的区域的宽度,例如全面屏设备下会减去 safeAreaInsets.left/right,InsetGrouped 样式下会减去左右的缩进。
  10. UITableViewCell(QMUI) 增加以下特性:
    1. 增加 qmui_style 属性用于获取初始化 cell 时指定的 UITableViewCellStyle
    2. 增加 qmui_cellPosition 属性用于在 willDisplayCell 及以后的时机里能获取当前 cell 在 section 里的位置,如果是在 cellForRow 里则依然只能自己通过 -[UITableView qmui_positionForRowAtIndexPath:] 计算,无法使用 qmui_cellPosition
    3. 增加 qmui_separatorInsetsBlockqmui_topSeparatorInsetsBlock 用于控制 cell 的分隔线位置,由于 block 是渲染时才会调用,所以你可以在 block 里方便地根据当前 tableView 的 style、cell 的 position、cell 的 subviews 的布局来设置分隔线位置,这是系统自带的分隔线无法做到的事情。你可以在业务项目里 swizzle UITableViewCell 的 init 方法,在里面统一设置全局分隔线的逻辑,就无需每个 cell 子类都调整一次。
  11. UISearchBar(QMUI) 增加以下特性,对应地 QMUI Demo 也增加新的示例界面:QMUIKit→UISearchBar+QMUI→UISearchBar(QMUI)
    1. 增加 qmui_centerPlaceholder 用于让 iOS 11 及以后的搜索框 placeholder 也能默认居中(系统默认是居左)。
    2. 增加 qmui_leftAccessoryViewqmui_rightAccessoryView 支持在输入框左右各显示一个 view,从而你可以方便地添加自己的按钮(例如在搜索框左边显示一个返回按钮,在右边显示一个结果过滤、结果排序按钮等)。
  12. QMUIHelper 增加 executeBlock: oncePerIdentifier: 用于令某段逻辑只被执行一次,QMUIKit 中通常用来避免重复 swizzle 相同方法。
  13. QMUICommonDefines.h 增加 IOS14_SDK_ALLOWED 用于识别当前是 iOS 14 SDK 编译环境。
  14. UINavigationBarUITabBar 在没设置 backgroundImage 时也能正确显示 shadowImage(系统默认行为是只有设置了 backgroundImageshadowImage 才能生效),从而保证不同 iOS 系统里的表现一致。
  15. 感谢 @MaxwellLeeee 增加对 QMUIToastAnimator 里 Zoom 和 Slide 两种动画方式的支持。

会带来 QMUI 新旧版本兼容问题的更新

  1. 最低支持版本从 iOS 9.0 升级为 iOS 10.0。
  2. 重构 QMUIBadge 未读数组件,原本仅支持在 UIBarItem 上显示未读数/未读红点,现在可以在任意的 UIView 上显示未读数/未读红点了。同时为了优化使用体验,将原本基于中心布局的 qmui_badgeCenterOffsetqmui_badgeCenterOffsetLandscapeqmui_updatesIndicatorCenterOffsetqmui_updatesIndicatorCenterOffsetLandscape 4个属性标记为废弃,新组件将基于右上角布局,使用新属性 qmui_badgeOffsetqmui_badgeOffsetLandscapeqmui_updatesIndicatorOffsetqmui_updatesIndicatorOffsetLandscape 代替以前的4个旧属性。同时 QMUI Demo 里也增加了对应的示例代码。
  3. 对于 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;

如何适配新版

  1. 全局搜索“qmui_badgeCenterOffset”,改为用 qmui_badgeOffset,具体值要自行调整。
  2. 全局搜索“qmui_badgeCenterOffsetLandscape”,改为用 qmui_badgeOffsetLandscape,具体值要自行调整。
  3. 全局搜索“qmui_updatesIndicatorCenterOffset”,改为用 qmui_updatesIndicatorOffset,具体值要自行调整。
  4. 全局搜索“qmui_updatesIndicatorCenterOffsetLandscape”,改为用 qmui_updatesIndicatorOffsetLandscape,具体值要自行调整。
  5. 全局搜索“BadgeCenterOffset”,改为用 BadgeOffset
  6. 全局搜索“BadgeCenterOffsetLandscape”,改为用 BadgeOffsetLandscape
  7. 全局搜索“UpdatesIndicatorCenterOffset”,改为用 UpdatesIndicatorOffset
  8. 全局搜索“UpdatesIndicatorCenterOffsetLandscape”,改为用 UpdatesIndicatorOffsetLandscape
  9. 全局搜索对 QMUIAlertController.dismissKeyboardAutomatically 的使用,由于不支持 iOS 9,所以这个属性已经没用了,请删除。

如果有使用配置表

  1. 将以下代码添加到配置表里:
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
  1. 将以下设置项从配置表里删除:
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

  1. #997 修复输入框聚焦并升起键盘的情况下,App 进入后台再回到前台,键盘外观会错误的 bug。
  2. #1001 修复在 Mac Catalyst 里调用 +[UIImage qmui_imageWithThemeProvider] 会死循环的 bug。
  3. #1012 修复 QMUIPopupMenuButtonItem 内的 QMUIButton.imageView 可能出现负值的 bounds,导致一些布局错误的 bug。
  4. #1026 修复 iOS 12 及以下,UITabBarItem 只设置 image 没设置 selectedImage 时,无法通过配置表设置图片颜色的 bug。
  5. #1037 修复 QMUIToast 修改内容后布局没有刷新的 bug。
  6. #1042 修复 iOS 14 下切换到 emoji 键盘会 crash 的 bug。
  7. #1048 修复 `-[QMUIZoomImageView showEmptyViewWithText] 无法显示 emptyView 的 bug。
  8. #1051 修复 QMUIButton 搭配 Autolayout 使用时可能出现的文字布局错误的 bug。
  9. #1061 修复 CocoaPods Spec 文件里对 Photos.framework 的依赖写法,改为在 Subspec 内依赖,避免引入其他子模块时也错误地引入了 Photos.framework。
  10. #1063 修复 iOS 14 下当关闭 NeedsBackBarButtonItemTitle 后,长按返回按钮出现的快速返回菜单里无法显示标题的 bug。
  11. 修复 iOS 14 下修改了 UISearchBar 字体后会导致 searchBar 内的输入框高度错误的 bug。
  12. 修复 iOS 12 及以下 UITextField(QMUI).qmui_clearButtonImage 无效的 bug。
  13. 修复 QMUINavigationTitlteView 在 vertical 布局模式下,如果 subtitle 比 title 长的话可以看到 loading 和 accessoryView 与 title 之间间距过大的 bug。
  14. 修复 QMUINavigationTitleView 文字长度过长时没有截断的 bug。
  15. 修复使用 QMUINavigationButton 作为自定义返回按钮时,在 iOS 13.4.1 系统新增的 Full Keyboard Access 模式下无法使用快捷键 Tab+B 返回上一级界面的 bug。
  16. 修复 QMUIAppearance 无法在非 UIViewUIViewController 对象里使用的 bug。
  17. 修复 -[UIImage (QMUI) qmui_imageWithTintColor:]opaqueimage 效果错误的 bug。
  18. 修复 +[QMUIHelper compareSystemVersion:toVersion:] 返回结果相反的 bug。
  19. 修复 NSString(QMUI)qmui_substringAvoidBreakingUpCharacterSequencesFromIndex:lessValue:countingNonASCIICharacterAsTwo:qmui_substringAvoidBreakingUpCharacterSequencesToIndex:lessValue:countingNonASCIICharacterAsTwo: 裁剪不准确的 bug。
  20. 修复以下几个类的类方法里初始化实例的错误写法,导致如果是子类通过类方法得到的依然是父类的实例的 bug。
    1. QMUIAlertAction
    2. QMUIDisplayLinkAnimation
    3. QMUILogItem
    4. QMUIConsoleLogItem
    5. QMUIEmotion
    6. QMUIMoreOperationItemView
    7. QMUIMultipleDelegates
    8. QMUIPopupMenuButtonItem
    9. QMUIStaticTableViewCellData
    10. QMUIPropertyDescriptor
    11. UIBarButtonItem(QMUINavigatiaonButton)
    12. UIColor(QMUITheme)
    13. NSMutableParagraphStyle(QMUI)

其他

  1. 将原本属于 UIControl(QMUI)qmui_outsideEdge 属性迁移到 UIView(QMUI),使其适用于更多场景。
  2. 优化 QMUIModalPresentationViewController 在键盘位置发生变化时刷新布局的频率。
  3. 优化 QMUICommonTableViewController 手势返回过程中当前 selected 的那个 cell 的背景色可以跟随手势进度慢慢消失。
  4. QMUICommonTableViewController 里原本监听 contentInset 的 KVO 主体改为一个独立的对象,避免 QMUICommonTableViewController 的子类重写 observeValueForKeyPath:ofObject:change:context: 时不知道要调用 super 的问题。
  5. 去掉 -[CALayer(QMUI) qmui_sendSublayerToBack:]-[CALayer(QMUI) qmui_bringSublayerToFront:] 里对参数是否属于当前 layer 的 sublayers 的判断,使这两个方法更通用。
  6. 感谢 @kimwjc 优化对 UIAccessibility 无障碍访问的支持。