Skip to content

Commit

Permalink
2.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
MoLice committed Nov 17, 2018
1 parent e28e682 commit 03d3260
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 20 deletions.
2 changes: 1 addition & 1 deletion QMUIKit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.9.1</string>
<string>2.9.2</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,14 +417,17 @@ - (BOOL)shouldCustomTransitionAutomaticallyWithFirstViewController:(UIViewContro
}
}

UIColor *barTintColor1 = [vc1 respondsToSelector:@selector(navigationBarBarTintColor)] ? [vc1 navigationBarBarTintColor] : [UINavigationBar appearance].barTintColor;
UIColor *barTintColor2 = [vc2 respondsToSelector:@selector(navigationBarBarTintColor)] ? [vc2 navigationBarBarTintColor] : [UINavigationBar appearance].barTintColor;
if (barTintColor1 || barTintColor2) {
if (!barTintColor1 || !barTintColor2) {
return YES;
}
if (![barTintColor1 isEqual:barTintColor2]) {
return YES;
// 如果存在 backgroundImage,则 barTintColor 就算存在也不会被显示出来,所以这里只判断两个 backgroundImage 都不存在的时候
if (!bg1 && !bg2) {
UIColor *barTintColor1 = [vc1 respondsToSelector:@selector(navigationBarBarTintColor)] ? [vc1 navigationBarBarTintColor] : [UINavigationBar appearance].barTintColor;
UIColor *barTintColor2 = [vc2 respondsToSelector:@selector(navigationBarBarTintColor)] ? [vc2 navigationBarBarTintColor] : [UINavigationBar appearance].barTintColor;
if (barTintColor1 || barTintColor2) {
if (!barTintColor1 || !barTintColor2) {
return YES;
}
if (![barTintColor1 isEqual:barTintColor2]) {
return YES;
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions QMUIKit/QMUIComponents/QMUIButton/QMUIButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ - (CGSize)sizeThatFits:(CGSize)size {
// 图片和文字上下排版时,宽度以文字或图片的最大宽度为最终宽度
if (isImageViewShowing) {
CGFloat imageLimitWidth = contentLimitSize.width - UIEdgeInsetsGetHorizontalValue(self.imageEdgeInsets);
CGSize imageSize = self.currentImage.size;
CGSize imageSize = [self.imageView sizeThatFits:CGSizeMax];
imageSize.width = fmin(imageSize.width, imageLimitWidth);
imageTotalSize = CGSizeMake(imageSize.width + UIEdgeInsetsGetHorizontalValue(self.imageEdgeInsets), imageSize.height + UIEdgeInsetsGetVerticalValue(self.imageEdgeInsets));
}
Expand All @@ -102,7 +102,7 @@ - (CGSize)sizeThatFits:(CGSize)size {

if (isImageViewShowing) {
CGFloat imageLimitHeight = contentLimitSize.height - UIEdgeInsetsGetVerticalValue(self.imageEdgeInsets);
CGSize imageSize = self.currentImage.size;
CGSize imageSize = [self.imageView sizeThatFits:CGSizeMax];
imageSize.height = fmin(imageSize.height, imageLimitHeight);
imageTotalSize = CGSizeMake(imageSize.width + UIEdgeInsetsGetHorizontalValue(self.imageEdgeInsets), imageSize.height + UIEdgeInsetsGetVerticalValue(self.imageEdgeInsets));
}
Expand Down
3 changes: 3 additions & 0 deletions QMUIKit/QMUICore/QMUICommonDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
// 是否放大模式(iPhone 6及以上的设备支持放大模式)
#define IS_ZOOMEDMODE ([[UIScreen mainScreen] respondsToSelector:@selector(nativeScale)] ? (ScreenNativeScale > ScreenScale) : NO)

// 判断该用户是否开启了系统偏好里加粗文本功能(Bold Text)
#define IS_BOLDTEXT_ENABLED UIAccessibilityIsBoldTextEnabled()

#pragma mark - 变量-布局相关

// 获取一个像素
Expand Down
32 changes: 23 additions & 9 deletions QMUIKit/UIKitExtensions/CALayer+QMUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,18 @@ - (void)setQmui_maskedCorners:(QMUICornerMask)qmui_maskedCorners {
if (@available(iOS 11, *)) {
self.maskedCorners = (CACornerMask)qmui_maskedCorners;
} else {
if (qmui_maskedCorners && ![self hasFourBorder]) {
if (qmui_maskedCorners && ![self hasFourCornerRadius]) {
[self qmui_setCornerRadius:0];
}
if (maskedCornersChanged) {
// 需要刷新mask
[self setNeedsLayout];
if ([NSThread isMainThread]) {
[self setNeedsLayout];
} else {
dispatch_async(dispatch_get_main_queue(), ^{
[self setNeedsLayout];
});
}
}
}
if (maskedCornersChanged) {
Expand All @@ -107,7 +113,7 @@ - (void)setQmui_maskedCorners:(QMUICornerMask)qmui_maskedCorners {

- (QMUICornerMask)qmui_maskedCorners {
return [objc_getAssociatedObject(self, &kAssociatedObjectKey_maskedCorners) unsignedIntegerValue];
}
}

- (instancetype)qmui_init {
[self qmui_init];
Expand Down Expand Up @@ -141,12 +147,12 @@ - (void)qmui_setPosition:(CGPoint)position {
}

- (void)qmui_setCornerRadius:(CGFloat)cornerRadius {
BOOL cornerRadiusChanged = self.qmui_originCornerRadius != cornerRadius;
BOOL cornerRadiusChanged = flat(self.qmui_originCornerRadius) != flat(cornerRadius);
self.qmui_originCornerRadius = cornerRadius;
if (@available(iOS 11, *)) {
[self qmui_setCornerRadius:cornerRadius];
} else {
if (self.qmui_maskedCorners && ![self hasFourBorder]) {
if (self.qmui_maskedCorners && ![self hasFourCornerRadius]) {
[self qmui_setCornerRadius:0];
} else {
[self qmui_setCornerRadius:cornerRadius];
Expand Down Expand Up @@ -286,7 +292,7 @@ + (CALayer *)qmui_separatorLayerForTableView {
return layer;
}

- (BOOL)hasFourBorder {
- (BOOL)hasFourCornerRadius {
return (self.qmui_maskedCorners & QMUILayerMinXMinYCorner) == QMUILayerMinXMinYCorner &&
(self.qmui_maskedCorners & QMUILayerMaxXMinYCorner) == QMUILayerMaxXMinYCorner &&
(self.qmui_maskedCorners & QMUILayerMinXMaxYCorner) == QMUILayerMinXMaxYCorner &&
Expand All @@ -308,15 +314,23 @@ + (void)load {
});
}

static NSString *kMaskName = @"QMUI_CornerRadius_Mask";

- (void)QMUICornerRadius_layoutSublayersOfLayer:(CALayer *)layer {
[self QMUICornerRadius_layoutSublayersOfLayer:layer];
if (@available(iOS 11, *)) {
} else {
if (self.layer.mask && ![self.layer.mask.name isEqualToString:kMaskName]) {
return;
}
if (self.layer.qmui_maskedCorners) {
if (self.layer.qmui_originCornerRadius <= 0 || [self hasFourBorder]) {
self.layer.mask = nil;
if (self.layer.qmui_originCornerRadius <= 0 || [self hasFourCornerRadius]) {
if (self.layer.mask) {
self.layer.mask = nil;
}
} else {
CAShapeLayer *cornerMaskLayer = [CAShapeLayer layer];
cornerMaskLayer.name = kMaskName;
UIRectCorner rectCorner = 0;
if ((self.layer.qmui_maskedCorners & QMUILayerMinXMinYCorner) == QMUILayerMinXMinYCorner) {
rectCorner |= UIRectCornerTopLeft;
Expand All @@ -339,7 +353,7 @@ - (void)QMUICornerRadius_layoutSublayersOfLayer:(CALayer *)layer {
}
}

- (BOOL)hasFourBorder {
- (BOOL)hasFourCornerRadius {
return (self.layer.qmui_maskedCorners & QMUILayerMinXMinYCorner) == QMUILayerMinXMinYCorner &&
(self.layer.qmui_maskedCorners & QMUILayerMaxXMinYCorner) == QMUILayerMaxXMinYCorner &&
(self.layer.qmui_maskedCorners & QMUILayerMinXMaxYCorner) == QMUILayerMinXMaxYCorner &&
Expand Down

0 comments on commit 03d3260

Please sign in to comment.