Skip to content

Commit

Permalink
4.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
MoLice committed May 8, 2020
1 parent 3fdcada commit f2fdc21
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 12 deletions.
2 changes: 1 addition & 1 deletion 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.1.2"
s.version = "4.1.3"
s.summary = "致力于提高项目 UI 开发效率的解决方案"
s.description = <<-DESC
QMUI iOS 是一个致力于提高项目 UI 开发效率的解决方案,其设计目的是用于辅助快速搭建一个具备基本设计还原效果的 iOS 项目,同时利用自身提供的丰富控件及兼容处理, 让开发者能专注于业务需求而无需耗费精力在基础代码的设计上。不管是新项目的创建,或是已有项目的维护,均可使开发效率和项目质量得到大幅度提升。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ - (QMUIImagePreviewView *)imagePreviewView {
return _imagePreviewView;
}

- (void)viewDidLoad {
[super viewDidLoad];
- (void)initSubviews {
[super initSubviews];
self.view.backgroundColor = self.backgroundColor;
[self.view addSubview:self.imagePreviewView];
}
Expand Down
22 changes: 21 additions & 1 deletion QMUIKit/QMUICore/QMUICommonDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ betweenOrEqual(CGFloat minimumValue, CGFloat value, CGFloat maximumValue) {
* 例如 CGFloatToFixed(0.3333, 2) 会返回 0.33,而 CGFloatToFixed(0.6666, 2) 会返回 0.67
*
* @warning 参数类型为 CGFloat,也即意味着不管传进来的是 float 还是 double 最终都会被强制转换成 CGFloat 再做计算
* @warning 该方法无法解决浮点数精度运算的问题
* @warning 该方法无法解决浮点数精度运算的问题,如需做浮点数的 == 判断,可用下方的 CGFloatEqualToFloat()
*/
CG_INLINE CGFloat
CGFloatToFixed(CGFloat value, NSUInteger precision) {
Expand All @@ -360,6 +360,26 @@ CGFloatToFixed(CGFloat value, NSUInteger precision) {
return result;
}

/**
将给定的两个 CGFloat 进行等值比较,并通过参数 precision 指定要考虑的小数点后的精度,内部会将浮点数转成整型,从而避免浮点数精度导致的 == 判断错误。
例如 CGFloatEqualToFloatWithPrecision(1.000, 0.999, 0) 会返回 YES,但 1.000 == 0.999 会得到 NO。
*/
CG_INLINE BOOL
CGFloatEqualToFloatWithPrecision(CGFloat value1, CGFloat value2, NSUInteger precision) {
NSInteger a = ((NSInteger)round(value1) * pow(10, precision));
NSInteger b = ((NSInteger)round(value2) * pow(10, precision));
return a == b;
}

/**
将给定的两个 CGFloat 进行等值比较,不考虑小数点后的数值。
例如 CGFloatEqualToFloat(1.000, 0.999) 会返回 YES,但 1.000 == 0.999 会得到 NO。
*/
CG_INLINE BOOL
CGFloatEqualToFloat(CGFloat value1, CGFloat value2) {
return CGFloatEqualToFloatWithPrecision(value1, value2, 0);
}

/// 用于居中运算
CG_INLINE CGFloat
CGFloatGetCenter(CGFloat parent, CGFloat child) {
Expand Down
2 changes: 1 addition & 1 deletion QMUIKit/QMUIKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef QMUIKit_h
#define QMUIKit_h

static NSString * const QMUI_VERSION = @"4.1.2";
static NSString * const QMUI_VERSION = @"4.1.3";

#if __has_include("CAAnimation+QMUI.h")
#import "CAAnimation+QMUI.h"
Expand Down
15 changes: 10 additions & 5 deletions QMUIKit/UIKitExtensions/UIViewController+QMUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,16 @@ + (void)load {
&& selfObject.isViewLoaded) {
CGRect viewRectInTabBarController = [selfObject.view convertRect:selfObject.view.bounds toView:tabBarController.view];

if (CGRectGetHeight(viewRectInTabBarController) != CGRectGetHeight(tabBarController.view.bounds)) {
// 从没带 tabBar 的界面 pop 到带 tabBar 的界面过程中,navController.view.height 会被改得小一点,导致 safeAreaInsets.bottom 出现错误的中间值,引发 UIScrollView.contentInset 的错误变化,后续就算 contentInset 恢复正确,contentOffset 也无法恢复,所以这里直接过滤掉中间的错误值
// (但无法保证每个场景下这样的值都是错的,或许某些少见的场景里,navController.view.height 就是不会铺满整个 tabBarController.view.height 呢?)
// https://github.com/Tencent/QMUI_iOS/issues/934
return;
// 发现在 iOS 13.3 及以下,在 extendedLayoutIncludesOpaqueBars = YES 的情况下,理论上任何时候 vc.view 都应该撑满整个 tabBarController.view,但从没带 tabBar 的界面 pop 到带 tabBar 的界面过程中,navController.view.height 会被改得小一点,导致 safeAreaInsets.bottom 出现错误的中间值,引发 UIScrollView.contentInset 的错误变化,后续就算 contentInset 恢复正确,contentOffset 也无法恢复,所以这里直接过滤掉中间的错误值
// (但无法保证每个场景下这样的值都是错的,或许某些少见的场景里,navController.view.height 就是不会铺满整个 tabBarController.view.height 呢?)
// https://github.com/Tencent/QMUI_iOS/issues/934
if (@available(iOS 13.4, *)) {
} else {
if (!tabBar.translucent
&& selfObject.extendedLayoutIncludesOpaqueBars
&& !CGFloatEqualToFloat(CGRectGetHeight(viewRectInTabBarController), CGRectGetHeight(tabBarController.view.bounds))) {
return;
}
}

CGRect barRectInTabBarController = [tabBar convertRect:tabBar.bounds toView:tabBarController.view];
Expand Down
4 changes: 2 additions & 2 deletions qmui.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1852,7 +1852,7 @@
"@loader_path/Frameworks",
);
MACH_O_TYPE = mh_dylib;
MARKETING_VERSION = 4.1.2;
MARKETING_VERSION = 4.1.3;
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.qmui.QMUIKit;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -1896,7 +1896,7 @@
"@loader_path/Frameworks",
);
MACH_O_TYPE = mh_dylib;
MARKETING_VERSION = 4.1.2;
MARKETING_VERSION = 4.1.3;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = com.qmui.QMUIKit;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down

0 comments on commit f2fdc21

Please sign in to comment.