Skip to content

Commit

Permalink
4.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
MoLice committed Oct 31, 2019
1 parent fffddc9 commit 521eb08
Show file tree
Hide file tree
Showing 55 changed files with 418 additions and 537 deletions.
2 changes: 1 addition & 1 deletion QMUIConfigurationTemplate/QMUIConfigurationTemplate.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ - (void)applyConfigurationTemplate {
QMUICMI.fillButtonColorGray = UIColorGray; // FillButtonColorGray : QMUIFillButtonColorGray 的颜色
QMUICMI.fillButtonColorWhite = UIColorWhite; // FillButtonColorWhite : QMUIFillButtonColorWhite 的颜色

#pragma mark - TextField & TextView
#pragma mark - TextInput
QMUICMI.textFieldTintColor = nil; // TextFieldTintColor : QMUITextField、QMUITextView 的 tintColor,不影响 UIKit 的输入框
QMUICMI.textFieldTextInsets = UIEdgeInsetsMake(0, 7, 0, 7); // TextFieldTextInsets : QMUITextField 的内边距,不影响 UITextField
QMUICMI.keyboardAppearance = UIKeyboardAppearanceDefault; // KeyboardAppearance : UITextView、UITextField、UISearchBar 的 keyboardAppearance
Expand Down
11 changes: 2 additions & 9 deletions 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.0.2"
s.version = "4.0.3"
s.summary = "致力于提高项目 UI 开发效率的解决方案"
s.description = <<-DESC
QMUI iOS 是一个致力于提高项目 UI 开发效率的解决方案,其设计目的是用于辅助快速搭建一个具备基本设计还原效果的 iOS 项目,同时利用自身提供的丰富控件及兼容处理, 让开发者能专注于业务需求而无需耗费精力在基础代码的设计上。不管是新项目的创建,或是已有项目的维护,均可使开发效率和项目质量得到大幅度提升。
Expand All @@ -19,17 +19,14 @@ Pod::Spec.new do |s|
s.frameworks = 'Foundation', 'UIKit', 'CoreGraphics', 'Photos'
s.preserve_paths = 'QMUIConfigurationTemplate/*'
s.source_files = 'QMUIKit/QMUIKit.h'
s.resource_bundles = {'QMUIResources' => ['QMUIKit/QMUIResources/*.*']}

s.subspec 'QMUICore' do |ss|
ss.source_files = 'QMUIKit/QMUIKit.h', 'QMUIKit/QMUICore', 'QMUIKit/UIKitExtensions'
ss.dependency 'QMUIKit/QMUIWeakObjectContainer'
ss.dependency 'QMUIKit/QMUILog'
end

s.subspec 'QMUIResources' do |ss|
ss.resource = 'QMUIKit/QMUIResources/*.*'
end

s.subspec 'QMUIMainFrame' do |ss|
ss.source_files = 'QMUIKit/QMUIMainFrame'
ss.dependency 'QMUIKit/QMUICore'
Expand Down Expand Up @@ -149,7 +146,6 @@ Pod::Spec.new do |s|

ss.subspec 'QMUIConsole' do |sss|
sss.source_files = 'QMUIKit/QMUIComponents/QMUIConsole/*.{h,m}'
sss.dependency 'QMUIKit/QMUIResources'
sss.dependency 'QMUIKit/QMUIComponents/QMUITextView'
sss.dependency 'QMUIKit/QMUIComponents/QMUITextField'
sss.dependency 'QMUIKit/QMUIComponents/QMUIButton'
Expand All @@ -176,7 +172,6 @@ Pod::Spec.new do |s|
ss.subspec 'QMUIEmotionView' do |sss|
sss.source_files = 'QMUIKit/QMUIComponents/QMUIEmotionView.{h,m}'
sss.dependency 'QMUIKit/QMUIComponents/QMUIButton'
sss.dependency 'QMUIKit/QMUIResources'
end

ss.subspec 'QMUIFloatLayoutView' do |sss|
Expand Down Expand Up @@ -311,7 +306,6 @@ Pod::Spec.new do |s|
ss.subspec 'QMUITips' do |sss|
sss.source_files = 'QMUIKit/QMUIComponents/QMUITips.{h,m}'
sss.dependency 'QMUIKit/QMUIComponents/QMUIToastView'
sss.dependency 'QMUIKit/QMUIResources'
end

ss.subspec 'QMUIVisualEffectView' do |sss|
Expand All @@ -338,7 +332,6 @@ Pod::Spec.new do |s|
ss.subspec 'QMUIImagePickerLibrary' do |sss|
sss.source_files = 'QMUIKit/QMUIComponents/ImagePickerLibrary/*.{h,m}'
sss.dependency 'QMUIKit/QMUIMainFrame'
sss.dependency 'QMUIKit/QMUIResources'
sss.dependency 'QMUIKit/QMUIComponents/QMUIImagePreviewView'
sss.dependency 'QMUIKit/QMUIComponents/QMUITableViewCell'
sss.dependency 'QMUIKit/QMUIComponents/QMUIButton'
Expand Down
9 changes: 0 additions & 9 deletions QMUIKit/QMUIComponents/AssetLibrary/QMUIAsset.m
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,9 @@ - (NSInteger)requestPreviewImageWithCompletion:(void (^)(UIImage *result, NSDict

- (NSInteger)requestLivePhotoWithCompletion:(void (^)(PHLivePhoto *livePhoto, NSDictionary<NSString *, id> *info))completion withProgressHandler:(PHAssetImageProgressHandler)phProgressHandler {
if ([[PHCachingImageManager class] instancesRespondToSelector:@selector(requestLivePhotoForAsset:targetSize:contentMode:options:resultHandler:)]) {
#ifdef IOS13_SDK_ALLOWED
// 使用 iOS 13 SDK 编译,只要代码中有 PHLivePhotoRequestOptions 在 iOS 9.0 的机器上一启动就会 crash : dyld: Symbol not found: _OBJC_CLASS_$_PHLivePhotoRequestOptions,所以改成这种动态调用。
Class PHLivePhotoRequestOptionsClass = NSClassFromString(@"PHLivePhotoRequestOptions");
id livePhotoRequestOptions = [[PHLivePhotoRequestOptionsClass alloc] init];
BOOL networkAccessAllowed = YES;
[livePhotoRequestOptions qmui_performSelector:@selector(setNetworkAccessAllowed:) withArguments:&networkAccessAllowed, nil]; // 允许访问网络
[livePhotoRequestOptions qmui_performSelector:@selector(setProgressHandler:) withArguments:&phProgressHandler, nil];
#else
PHLivePhotoRequestOptions *livePhotoRequestOptions = [[PHLivePhotoRequestOptions alloc] init];
livePhotoRequestOptions.networkAccessAllowed = YES; // 允许访问网络
livePhotoRequestOptions.progressHandler = phProgressHandler;
#endif
return [[[QMUIAssetsManager sharedInstance] phCachingImageManager] requestLivePhotoForAsset:_phAsset targetSize:CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT) contentMode:PHImageContentModeDefault options:livePhotoRequestOptions resultHandler:^(PHLivePhoto * _Nullable livePhoto, NSDictionary * _Nullable info) {
if (completion) {
completion(livePhoto, info);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ - (void)viewWillAppear:(BOOL)animated {
self.checkboxButton.selected = [self.selectedImageAssetArray containsObject:imageAsset];
}

BeginIgnoreDeprecatedWarning
[[UIApplication sharedApplication] setStatusBarHidden:YES];
EndIgnoreDeprecatedWarning

if ([self conformsToProtocol:@protocol(QMUICustomNavigationBarTransitionDelegate)]) {
UIViewController<QMUICustomNavigationBarTransitionDelegate> *vc = (UIViewController<QMUICustomNavigationBarTransitionDelegate> *)self;
if ([vc respondsToSelector:@selector(shouldCustomizeNavigationBarTransitionIfHideable)] &&
Expand All @@ -126,10 +122,6 @@ - (void)viewWillAppear:(BOOL)animated {
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];

BeginIgnoreDeprecatedWarning
[[UIApplication sharedApplication] setStatusBarHidden:NO];
EndIgnoreDeprecatedWarning

if ([self conformsToProtocol:@protocol(QMUICustomNavigationBarTransitionDelegate)]) {
UIViewController<QMUICustomNavigationBarTransitionDelegate> *vc = (UIViewController<QMUICustomNavigationBarTransitionDelegate> *)self;
if ([vc respondsToSelector:@selector(shouldCustomizeNavigationBarTransitionIfHideable)] &&
Expand Down
1 change: 1 addition & 0 deletions QMUIKit/QMUIComponents/QMUIAlertController.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ typedef NS_ENUM(NSInteger, QMUIAlertControllerStyle) {
@property(nonatomic, assign) BOOL isExtendBottomLayout UI_APPEARANCE_SELECTOR;

/// 在显示 alert 之前先降下键盘,默认为 YES。系统的 UIAlertController 也会在显示时降下键盘,但它能在消失后把键盘自动升起,并且这个过程不会触发 becomeFirstResponder/resignFirstResponder,QMUIAlertController 暂时做不到这样的效果,只负责降下,不负责恢复。
/// iOS 10 及以上,一个 UIWindow 显示出来时默认就会降下键盘,所以这个属性只在 iOS 9 里有效,iOS 10 及以上即便设置为 NO 也没有效果。
@property(nonatomic, assign) BOOL dismissKeyboardAutomatically;

@end
Expand Down
8 changes: 6 additions & 2 deletions QMUIKit/QMUIComponents/QMUIAlertController.m
Original file line number Diff line number Diff line change
Expand Up @@ -897,8 +897,12 @@ - (void)showWithAnimated:(BOOL)animated {
if (self.alertTextFields.count > 0) {
[self.alertTextFields.firstObject becomeFirstResponder];
} else {
if (self.dismissKeyboardAutomatically && [QMUIKeyboardManager isKeyboardVisible]) {
[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];
// iOS 10 及以上的版本在显示 window 时都会自动降下当前 App 的键盘,所以只有 iOS 9 及以下才需要手动处理
if (@available(iOS 10.0, *)) {
} else {
if (self.dismissKeyboardAutomatically && [QMUIKeyboardManager isKeyboardVisible]) {
[UIApplication.sharedApplication sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];
}
}
}
if (_needsUpdateAction) {
Expand Down
135 changes: 8 additions & 127 deletions QMUIKit/QMUIComponents/QMUIButton/QMUINavigationButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ @interface UINavigationBar (QMUINavigationButton)
@property(nonatomic, weak, readonly) UIView *qmui_contentView;

/// 判断当前的 UINavigationBar 的返回按钮是不是自定义的
@property(nonatomic, assign) BOOL qmui_customizingBackBarButtonItem;
@property(nonatomic, readonly) BOOL qmui_customizingBackBarButtonItem;
@end

@implementation UIBarButtonItem (QMUINavigationButton_Private)
Expand Down Expand Up @@ -431,17 +431,6 @@ - (void)qmui_setLeftBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animate

// 自动给 position 赋值
item.qmui_navigationButton.buttonPosition = QMUINavigationButtonPositionLeft;

// iOS 11,调整自定义返回按钮的位置 https://github.com/Tencent/QMUI_iOS/issues/279
if (@available(iOS 11, *)) {
UINavigationBar *navigationBar = self.qmui_navigationBar;
if (!navigationBar) return;

// 这个保护对应这个 issue:https://github.com/Tencent/QMUI_iOS/issues/335
if ([navigationBar.items containsObject:self] && navigationBar.topItem != self) return;

navigationBar.qmui_customizingBackBarButtonItem = item.qmui_isCustomizedBackBarButtonItem;
}
}

- (void)qmui_setLeftBarButtonItems:(NSArray<UIBarButtonItem *> *)items animated:(BOOL)animated {
Expand All @@ -460,25 +449,6 @@ - (void)qmui_setLeftBarButtonItems:(NSArray<UIBarButtonItem *> *)items animated:
items[i].qmui_navigationButton.buttonPosition = QMUINavigationButtonPositionNone;
}
}

// iOS 11,调整自定义返回按钮的位置 https://github.com/Tencent/QMUI_iOS/issues/279
if (@available(iOS 11, *)) {

UINavigationBar *navigationBar = self.qmui_navigationBar;
if (!navigationBar) return;

// 这个保护对应这个 issue:https://github.com/Tencent/QMUI_iOS/issues/335
if ([navigationBar.items containsObject:self] && navigationBar.topItem != self) return;

BOOL customizingBackBarButtonItem = NO;
for (UIBarButtonItem *item in items) {
if (item.qmui_isCustomizedBackBarButtonItem) {
customizingBackBarButtonItem = YES;
break;
}
}
navigationBar.qmui_customizingBackBarButtonItem = customizingBackBarButtonItem;
}
}

- (void)qmui_setRightBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated {
Expand Down Expand Up @@ -575,46 +545,6 @@ + (void)load {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{

OverrideImplementation([UINavigationBar class], @selector(pushNavigationItem:animated:), ^id(__unsafe_unretained Class originClass, SEL originCMD, IMP (^originalIMPProvider)(void)) {
return ^(UINavigationBar *selfObject, UINavigationItem *item, BOOL animated) {

// iOS 11,调整自定义返回按钮的位置 https://github.com/Tencent/QMUI_iOS/issues/279
BOOL shouldSetTagBeforeCallingSuper = NO;// 如果要 push 进的新 item 本身就是自定义返回按钮,那么要先打好标记再调用 super,否则先调用 super 再打标记,实测只有这样才不会导致跳动
if (@available(iOS 11, *)) {
shouldSetTagBeforeCallingSuper = item.leftBarButtonItem.qmui_isCustomizedBackBarButtonItem;
}

if (shouldSetTagBeforeCallingSuper) {
selfObject.qmui_customizingBackBarButtonItem = item.leftBarButtonItem.qmui_isCustomizedBackBarButtonItem;
}

// call super
void (*originSelectorIMP)(id, SEL, UINavigationItem *, BOOL);
originSelectorIMP = (void (*)(id, SEL, UINavigationItem *, BOOL))originalIMPProvider();
originSelectorIMP(selfObject, originCMD, item, animated);

if (!shouldSetTagBeforeCallingSuper) {
selfObject.qmui_customizingBackBarButtonItem = item.leftBarButtonItem.qmui_isCustomizedBackBarButtonItem;
}
};
});

// 对应 UINavigationController setViewControllers:animated:
OverrideImplementation([UINavigationBar class], @selector(setItems:animated:), ^id(__unsafe_unretained Class originClass, SEL originCMD, IMP (^originalIMPProvider)(void)) {
return ^(UINavigationBar *selfObject, NSArray<UINavigationItem *> *items, BOOL animated) {

// iOS 11,调整自定义返回按钮的位置 https://github.com/Tencent/QMUI_iOS/issues/279
if (@available(iOS 11, *)) {
selfObject.qmui_customizingBackBarButtonItem = items.lastObject.leftBarButtonItem.qmui_isCustomizedBackBarButtonItem;
}

// call super
void (*originSelectorIMP)(id, SEL, NSArray<UINavigationItem *> *, BOOL);
originSelectorIMP = (void (*)(id, SEL, NSArray<UINavigationItem *> *, BOOL))originalIMPProvider();
originSelectorIMP(selfObject, originCMD, items, animated);
};
});

// 强制修改 contentView 的 directionalLayoutMargins.leading,在使用自定义返回按钮时减小 8
// Xcode11 beta2 修改私有 view 的 directionalLayoutMargins 会 crash,换个方式
if (@available(iOS 11, *)) {
Expand Down Expand Up @@ -651,6 +581,13 @@ + (void)load {
});
}

- (BOOL)qmui_customizingBackBarButtonItem {
if (self.topItem.leftBarButtonItem) {
return self.topItem.leftBarButtonItem.qmui_isCustomizedBackBarButtonItem;
}
return NO;
}

- (UIView *)qmui_contentView {
for (UIView *subview in self.subviews) {
if ([NSStringFromClass(subview.class) containsString:@"BarContentView"]) {
Expand All @@ -660,60 +597,4 @@ - (UIView *)qmui_contentView {
return nil;
}

static char kAssociatedObjectKey_customizingBackBarButtonItem;
- (void)setQmui_customizingBackBarButtonItem:(BOOL)qmui_customizingBackBarButtonItem {
objc_setAssociatedObject(self, &kAssociatedObjectKey_customizingBackBarButtonItem, @(qmui_customizingBackBarButtonItem), OBJC_ASSOCIATION_RETAIN_NONATOMIC);

// 触发 UINavigationBar 的 layoutSubviews,在那里面会去更新 contentView 的 layoutMargins
if (@available(iOS 11, *)) {
[self setNeedsLayout];
[self layoutIfNeeded];
}
}

- (BOOL)qmui_customizingBackBarButtonItem {
return [((NSNumber *)objc_getAssociatedObject(self, &kAssociatedObjectKey_customizingBackBarButtonItem)) boolValue];
}

@end

@interface UINavigationController (QMUINavigationButton)

@end

@implementation UINavigationController (QMUINavigationButton)

+ (void)load {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{

// iOS 11,调整自定义返回按钮的位置 https://github.com/Tencent/QMUI_iOS/issues/279
if (@available(iOS 11, *)) {

ExtendImplementationOfNonVoidMethodWithTwoArguments([UINavigationController class], @selector(navigationBar:shouldPopItem:), UINavigationBar *, UINavigationItem *, BOOL, ^BOOL(UINavigationController *selfObject, UINavigationBar *navigationBar, UINavigationItem *item, BOOL originReturnValue) {
if (originReturnValue) {
BOOL isPopedByCoding = item != navigationBar.topItem;
if (!isPopedByCoding) {
if (navigationBar.items.count == 2 && !navigationBar.backItem.leftBarButtonItem && item.leftBarButtonItem.qmui_isCustomizedBackBarButtonItem) {
// 如果从自定义返回按钮界面返回到根界面,且根界面左上角没有按钮,则不调整 layout,不然会有跳动。理论上不应该这么改,但暂时没想到优雅的解决方式
} else {
// https://github.com/Tencent/QMUI_iOS/issues/737 这里要考虑自定义返回按钮的情况,leftBarButtonItem 和 backBarButtonItem 同时存在的情况下,leftBarButtonItem 会优先显示
if (navigationBar.topItem.leftBarButtonItem) {
// topViewController.navigationItem.leftBarButtonItem
navigationBar.qmui_customizingBackBarButtonItem = navigationBar.topItem.leftBarButtonItem.qmui_isCustomizedBackBarButtonItem;
} else if (navigationBar.backItem.leftBarButtonItem) {
// topViewController.navigationItem.backBarButtonItem
navigationBar.qmui_customizingBackBarButtonItem = navigationBar.backItem.leftBarButtonItem.qmui_isCustomizedBackBarButtonItem;
} else {
navigationBar.qmui_customizingBackBarButtonItem = NO;
}
}
}
}
return originReturnValue;
});
}
});
}

@end
8 changes: 8 additions & 0 deletions QMUIKit/QMUIComponents/QMUIDialogViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,18 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, assign) UIEdgeInsets dialogViewMargins UI_APPEARANCE_SELECTOR;
@property(nonatomic, assign) CGFloat maximumContentViewWidth UI_APPEARANCE_SELECTOR;
@property(nullable, nonatomic, strong) UIColor *backgroundColor UI_APPEARANCE_SELECTOR;

/// 标题的 tintColor,当没有设置 titleLabelTextColor 和 subTitleLabelTextColor 的情况下,标题和副标题的颜色均会使用 titleTintColor,当 titleLabelTextColor 和 subTitleLabelTextColor 其中任何一个被设置了值时,则 titleTintColor 作为候选项使用(也即谁为 nil 才会用 titleTintColor 顶替,不为 nil 则不会用到 titleTintColor)。
/// 默认为 nil
@property(nullable, nonatomic, strong) UIColor *titleTintColor UI_APPEARANCE_SELECTOR;
@property(nullable, nonatomic, strong) UIFont *titleLabelFont UI_APPEARANCE_SELECTOR;

/// 主标题的文字颜色,当为 nil 时则会使用 titleView 的 tintColor 作为文字颜色
@property(nullable, nonatomic, strong) UIColor *titleLabelTextColor UI_APPEARANCE_SELECTOR;
@property(nullable, nonatomic, strong) UIFont *subTitleLabelFont UI_APPEARANCE_SELECTOR;

/// 副标题的文字颜色,当为 nil 时则会使用 titleView 的 tintColor 作为文字颜色
/// @note 副标题可通过 dialog.titleView.subtitle 来设置
@property(nullable, nonatomic, strong) UIColor *subTitleLabelTextColor UI_APPEARANCE_SELECTOR;
@property(nullable, nonatomic, strong) UIColor *headerSeparatorColor UI_APPEARANCE_SELECTOR;
@property(nonatomic, assign) CGFloat headerViewHeight UI_APPEARANCE_SELECTOR;
Expand Down
Loading

0 comments on commit 521eb08

Please sign in to comment.