Skip to content

Commit ffd355f

Browse files
committed
3.1.3
1 parent 0a5294b commit ffd355f

19 files changed

Lines changed: 93 additions & 28 deletions

QMUIKit.podspec

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

QMUIKit/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>3.1.2</string>
18+
<string>3.1.3</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSPrincipalClass</key>

QMUIKit/QMUIComponents/ImagePickerLibrary/QMUIImagePickerViewController.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@
9595

9696
@property(nonatomic, weak) id<QMUIImagePickerViewControllerDelegate> imagePickerViewControllerDelegate;
9797

98-
/// 图片的最小尺寸,布局时如果有剩余空间,会将空间分配给图片大小,所以最终显示出来的大小不一定等于minimumImageWidth。默认是75。
98+
/*
99+
* 图片的最小尺寸,布局时如果有剩余空间,会将空间分配给图片大小,所以最终显示出来的大小不一定等于minimumImageWidth。默认是75。
100+
* @warning collectionViewLayout 和 collectionView 可能有设置 sectionInsets 和 contentInsets,所以设置几行不可以简单的通过 screenWdith / columnCount 来获得
101+
*/
99102
@property(nonatomic, assign) CGFloat minimumImageWidth UI_APPEARANCE_SELECTOR;
100103

101104
@property(nonatomic, strong, readonly) UICollectionViewFlowLayout *collectionViewLayout;

QMUIKit/QMUIComponents/ImagePickerLibrary/QMUIImagePickerViewController.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ - (void)initSubviews {
9696
[super initSubviews];
9797

9898
_collectionViewLayout = [[UICollectionViewFlowLayout alloc] init];
99-
CGFloat inset = PixelOne * 2;// no why, just beautiful
99+
CGFloat inset = PixelOne * 2; // no why, just beautiful
100100
self.collectionViewLayout.sectionInset = UIEdgeInsetsMake(inset, inset, inset, inset);
101101
self.collectionViewLayout.minimumLineSpacing = self.collectionViewLayout.sectionInset.bottom;
102102
self.collectionViewLayout.minimumInteritemSpacing = self.collectionViewLayout.sectionInset.left;
@@ -285,15 +285,15 @@ - (void)initPreviewViewControllerIfNeeded {
285285

286286
- (CGSize)referenceImageSize {
287287
CGFloat collectionViewWidth = CGRectGetWidth(self.collectionView.bounds);
288-
CGFloat collectionViewContentSpacing = collectionViewWidth - UIEdgeInsetsGetHorizontalValue(self.collectionView.contentInset);
288+
CGFloat collectionViewContentSpacing = collectionViewWidth - UIEdgeInsetsGetHorizontalValue(self.collectionView.contentInset) - UIEdgeInsetsGetHorizontalValue(self.collectionViewLayout.sectionInset);
289289
NSInteger columnCount = floor(collectionViewContentSpacing / self.minimumImageWidth);
290290
CGFloat referenceImageWidth = self.minimumImageWidth;
291-
BOOL isSpacingEnoughWhenDisplayInMinImageSize = UIEdgeInsetsGetHorizontalValue(self.collectionViewLayout.sectionInset) + (self.minimumImageWidth + self.collectionViewLayout.minimumInteritemSpacing) * columnCount - self.collectionViewLayout.minimumInteritemSpacing <= collectionViewContentSpacing;
291+
BOOL isSpacingEnoughWhenDisplayInMinImageSize = (self.minimumImageWidth + self.collectionViewLayout.minimumInteritemSpacing) * columnCount - self.collectionViewLayout.minimumInteritemSpacing <= collectionViewContentSpacing;
292292
if (!isSpacingEnoughWhenDisplayInMinImageSize) {
293293
// 算上图片之间的间隙后发现其实还是放不下啦,所以得把列数减少,然后放大图片以撑满剩余空间
294294
columnCount -= 1;
295295
}
296-
referenceImageWidth = (collectionViewContentSpacing - UIEdgeInsetsGetHorizontalValue(self.collectionViewLayout.sectionInset) - self.collectionViewLayout.minimumInteritemSpacing * (columnCount - 1)) / columnCount;
296+
referenceImageWidth = floor((collectionViewContentSpacing - self.collectionViewLayout.minimumInteritemSpacing * (columnCount - 1)) / columnCount);
297297
return CGSizeMake(referenceImageWidth, referenceImageWidth);
298298
}
299299

QMUIKit/QMUIComponents/QMUIBadge/UIBarItem+QMUIBadge.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ + (void)load {
5757
}
5858

5959
if (selfObject == firstArgv) {
60-
NSString *log = [NSString stringWithFormat:@"UITabBarButton addSubview:, 把自己作为 subview 添加到自己身上\n%@", [NSThread callStackSymbols]];
60+
NSString *log = [NSString stringWithFormat:@"UITabBarButton addSubview:, 把自己作为 subview 添加到自己身上,self = %@, viewController = %@, navigationController = %@\n%@", selfObject, selfObject.qmui_viewController, selfObject.qmui_viewController.navigationController, [NSThread callStackSymbols]];
6161
NSAssert(NO, log);
6262
QMUILogWarn(@"UIBarItem (QMUIBadge)", @"%@", log);
6363
}

QMUIKit/QMUIComponents/QMUILabel.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,15 @@ - (CGSize)intrinsicContentSize {
5050
}
5151

5252
- (void)drawTextInRect:(CGRect)rect {
53-
return [super drawTextInRect:UIEdgeInsetsInsetRect(rect, self.contentEdgeInsets)];
53+
rect = UIEdgeInsetsInsetRect(rect, self.contentEdgeInsets);
54+
55+
// 在某些情况下文字位置错误,因此做了如下保护
56+
// https://github.com/Tencent/QMUI_iOS/issues/529
57+
if (self.numberOfLines == 1 && (self.lineBreakMode == NSLineBreakByWordWrapping || self.lineBreakMode == NSLineBreakByCharWrapping)) {
58+
rect = CGRectSetHeight(rect, CGRectGetHeight(rect) + self.contentEdgeInsets.top * 2);
59+
}
60+
61+
[super drawTextInRect:rect];
5462
}
5563

5664
- (void)setHighlightedBackgroundColor:(UIColor *)highlightedBackgroundColor {

QMUIKit/QMUIComponents/QMUIPopupContainerView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ - (void)setSourceBarItem:(__kindof UIBarItem *)sourceBarItem {
224224
weakSelf.sourceRect = rect;
225225
};
226226
}
227-
if (sourceBarItem.qmui_view) {
227+
if (sourceBarItem.qmui_view && sourceBarItem.qmui_viewLayoutDidChangeBlock) {
228228
sourceBarItem.qmui_viewLayoutDidChangeBlock(sourceBarItem, sourceBarItem.qmui_view);// update layout immediately
229229
}
230230
}

QMUIKit/QMUICore/QMUICommonDefines.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@
120120
/// 是否Retina
121121
#define IS_RETINASCREEN ([[UIScreen mainScreen] scale] >= 2.0)
122122

123-
/// 是否放大模式(iPhone 6及以上的设备支持放大模式)
124-
#define IS_ZOOMEDMODE ([[UIScreen mainScreen] respondsToSelector:@selector(nativeScale)] ? (ScreenNativeScale > ScreenScale) : NO)
123+
/// 是否放大模式(iPhone 6及以上的设备支持放大模式,iPhone X 除外
124+
#define IS_ZOOMEDMODE [QMUIHelper isZoomedMode]
125125

126126
#pragma mark - 变量-布局相关
127127

QMUIKit/QMUICore/QMUIHelper.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ extern NSString *const _Nonnull QMUIResourcesMainBundleName;
131131

132132
@interface QMUIHelper (Device)
133133

134-
+ (NSString *)deviceModel;
134+
+ (nonnull NSString *)deviceModel;
135135

136136
+ (BOOL)isIPad;
137137
+ (BOOL)isIPod;
@@ -181,6 +181,9 @@ extern NSString *const _Nonnull QMUIResourcesMainBundleName;
181181
/// 判断当前设备是否高性能设备,只会判断一次,以后都直接读取结果,所以没有性能问题
182182
+ (BOOL)isHighPerformanceDevice;
183183

184+
/// 系统设置里是否开启了“放大显示-试图-放大”,支持放大模式的 iPhone 设备可在官方文档中查询 https://support.apple.com/zh-cn/guide/iphone/iphd6804774e/ios
185+
+ (BOOL)isZoomedMode;
186+
184187
@end
185188

186189
@interface QMUIHelper (UIApplication)

QMUIKit/QMUICore/QMUIHelper.m

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,24 @@ + (BOOL)isHighPerformanceDevice {
518518
return isHighPerformanceDevice > 0;
519519
}
520520

521+
+ (BOOL)isZoomedMode {
522+
if (!IS_IPHONE) {
523+
return NO;
524+
}
525+
526+
CGFloat nativeScale = UIScreen.mainScreen.nativeScale;
527+
CGFloat scale = UIScreen.mainScreen.scale;
528+
529+
// 对于所有的 Plus 系列 iPhone,屏幕物理像素低于软件层面的渲染像素,不管标准模式还是放大模式,nativeScale 均小于 scale,所以需要特殊处理才能准确区分放大模式
530+
// https://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions
531+
BOOL shouldBeDownsampledDevice = CGSizeEqualToSize(UIScreen.mainScreen.nativeBounds.size, CGSizeMake(1080, 1920));
532+
if (shouldBeDownsampledDevice) {
533+
scale /= 1.15;
534+
}
535+
536+
return nativeScale > scale;
537+
}
538+
521539
- (void)handleAppSizeWillChange:(NSNotification *)notification {
522540
preferredLayoutWidth = -1;
523541
}

0 commit comments

Comments
 (0)