Skip to content

Commit

Permalink
2.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
MoLice committed Jul 5, 2018
1 parent cab48b1 commit 7e0f488
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
*/
- (void)imagePickerViewController:(QMUIImagePickerViewController *)imagePickerViewController didSelectImageWithImagesAsset:(QMUIAsset *)imageAsset afterImagePickerPreviewViewControllerUpdate:(QMUIImagePickerPreviewViewController *)imagePickerPreviewViewController;

/// 是否能够选中 checkbox
- (BOOL)imagePickerViewController:(QMUIImagePickerViewController *)imagePickerViewController shouldCheckImageAtIndex:(NSInteger)index;

/// 即将选中 checkbox 时调用
- (void)imagePickerViewController:(QMUIImagePickerViewController *)imagePickerViewController willCheckImageAtIndex:(NSInteger)index;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,10 @@ - (void)handleCancelPickerImage:(id)sender {
- (void)handleCheckBoxButtonClick:(UIButton *)checkboxButton {
NSIndexPath *indexPath = [self.collectionView qmui_indexPathForItemAtView:checkboxButton];

if ([self.imagePickerViewControllerDelegate respondsToSelector:@selector(imagePickerViewController:shouldCheckImageAtIndex:)] && ![self.imagePickerViewControllerDelegate imagePickerViewController:self shouldCheckImageAtIndex:indexPath.item]) {
return;
}

QMUIImagePickerCollectionViewCell *cell = (QMUIImagePickerCollectionViewCell *)[self.collectionView cellForItemAtIndexPath:indexPath];
QMUIAsset *imageAsset = [self.imagesAssetArray objectAtIndex:indexPath.item];
if (cell.checked) {
Expand Down
6 changes: 3 additions & 3 deletions QMUIKit/QMUIComponents/QMUITips.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ - (void)showSucceed:(NSString *)text detailText:(NSString *)detailText {
}

- (void)showSucceed:(NSString *)text detailText:(NSString *)detailText hideAfterDelay:(NSTimeInterval)delay {
self.contentCustomView = [[UIImageView alloc] initWithImage:[QMUIHelper imageWithName:@"QMUI_tips_done"]];
self.contentCustomView = [[UIImageView alloc] initWithImage:[[QMUIHelper imageWithName:@"QMUI_tips_done"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]];
[self showTipWithText:text detailText:detailText hideAfterDelay:delay];
}

Expand All @@ -95,7 +95,7 @@ - (void)showError:(NSString *)text detailText:(NSString *)detailText {
}

- (void)showError:(NSString *)text detailText:(NSString *)detailText hideAfterDelay:(NSTimeInterval)delay {
self.contentCustomView = [[UIImageView alloc] initWithImage:[QMUIHelper imageWithName:@"QMUI_tips_error"]];
self.contentCustomView = [[UIImageView alloc] initWithImage:[[QMUIHelper imageWithName:@"QMUI_tips_error"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]];
[self showTipWithText:text detailText:detailText hideAfterDelay:delay];
}

Expand All @@ -112,7 +112,7 @@ - (void)showInfo:(NSString *)text detailText:(NSString *)detailText {
}

- (void)showInfo:(NSString *)text detailText:(NSString *)detailText hideAfterDelay:(NSTimeInterval)delay {
self.contentCustomView = [[UIImageView alloc] initWithImage:[QMUIHelper imageWithName:@"QMUI_tips_info"]];
self.contentCustomView = [[UIImageView alloc] initWithImage:[[QMUIHelper imageWithName:@"QMUI_tips_info"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]];
[self showTipWithText:text detailText:detailText hideAfterDelay:delay];
}

Expand Down
5 changes: 3 additions & 2 deletions QMUIKit/QMUIComponents/ToastView/QMUIToastContentView.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

/**
* `QMUIToastView`默认使用的contentView。其结构是:customView->textLabel->detailTextLabel等三个view依次往下排列。其中customView可以赋值任意的UIView或者自定义的view。
* 注意,customView 会响应 tintColor 的变化。而 textLabel/detailTextLabel 在没设置颜色到 attributes 里的情况下,也会跟随 tintColor 变化,设置了 attributes 的颜色则优先使用 attributes 里的颜色。
*
* @TODO: 增加多种类型的progressView的支持。
*/
Expand Down Expand Up @@ -66,12 +67,12 @@
@property(nonatomic, assign) CGFloat detailTextLabelMarginBottom UI_APPEARANCE_SELECTOR;

/**
* 设置textLabel的attributes
* 设置textLabel的attributes,如果包含 NSForegroundColorAttributeName 则 textLabel 不响应 tintColor,如果不包含则 textLabel 会拿 tintColor 当成文字颜色
*/
@property(nonatomic, strong) NSDictionary <NSString *, id> *textLabelAttributes UI_APPEARANCE_SELECTOR;

/**
* 设置detailTextLabel的attributes
* 设置 detailTextLabel 的 attributes,如果包含 NSForegroundColorAttributeName 则 detailTextLabel 不响应 tintColor,如果不包含则 detailTextLabel 会拿 tintColor 当成文字颜色
*/
@property(nonatomic, strong) NSDictionary <NSString *, id> *detailTextLabelAttributes UI_APPEARANCE_SELECTOR;

Expand Down
36 changes: 10 additions & 26 deletions QMUIKit/QMUIComponents/ToastView/QMUIToastContentView.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,12 @@
#import "UIView+QMUI.h"
#import "NSParagraphStyle+QMUI.h"

#define DefaultTextLabelFont UIFontBoldMake(16)
#define DefaultDetailTextLabelFont UIFontBoldMake(12)
#define DefaultLabelColor UIColorWhite

@implementation QMUIToastContentView

- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {

self.layer.allowsGroupOpacity = NO;

[self initSubviews];
}
return self;
Expand All @@ -32,17 +26,11 @@ - (void)initSubviews {

_textLabel = [[UILabel alloc] init];
self.textLabel.numberOfLines = 0;
self.textLabel.textAlignment = NSTextAlignmentCenter;
self.textLabel.textColor = DefaultLabelColor;
self.textLabel.font = DefaultTextLabelFont;
self.textLabel.opaque = NO;
[self addSubview:self.textLabel];

_detailTextLabel = [[UILabel alloc] init];
self.detailTextLabel.numberOfLines = 0;
self.detailTextLabel.textAlignment = NSTextAlignmentCenter;
self.detailTextLabel.textColor = DefaultLabelColor;
self.detailTextLabel.font = DefaultDetailTextLabelFont;
self.detailTextLabel.opaque = NO;
[self addSubview:self.detailTextLabel];
}
Expand Down Expand Up @@ -151,31 +139,27 @@ - (void)layoutSubviews {
}

- (void)tintColorDidChange {
[super tintColorDidChange];

if (self.customView) {
[self updateCustomViewTintColor];
}

NSMutableDictionary *textLabelAttributes = [[NSMutableDictionary alloc] initWithDictionary:self.textLabelAttributes];
textLabelAttributes[NSForegroundColorAttributeName] = self.tintColor;
self.textLabelAttributes = textLabelAttributes;
self.textLabelText = self.textLabelText;
// 如果通过 attributes 设置了文字颜色,则不再响应 tintColor
if (!self.textLabelAttributes[NSForegroundColorAttributeName]) {
self.textLabel.textColor = self.tintColor;
}

NSMutableDictionary *detailTextLabelAttributes = [[NSMutableDictionary alloc] initWithDictionary:self.detailTextLabelAttributes];
detailTextLabelAttributes[NSForegroundColorAttributeName] = self.tintColor;
self.detailTextLabelAttributes = detailTextLabelAttributes;
self.detailTextLabelText = self.detailTextLabelText;
if (!self.detailTextLabelAttributes[NSForegroundColorAttributeName]) {
self.detailTextLabel.textColor = self.tintColor;
}
}

- (void)updateCustomViewTintColor {
if (!self.customView) {
return;
}
self.customView.tintColor = self.tintColor;
if ([self.customView isKindOfClass:[UIImageView class]]) {
UIImageView *customView = (UIImageView *)self.customView;
customView.image = [customView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
}
if ([self.customView isKindOfClass:[UIActivityIndicatorView class]]) {
UIActivityIndicatorView *customView = (UIActivityIndicatorView *)self.customView;
customView.color = self.tintColor;
Expand Down Expand Up @@ -248,8 +232,8 @@ + (void)setDefaultAppearance {
appearance.customViewMarginBottom = 8;
appearance.textLabelMarginBottom = 4;
appearance.detailTextLabelMarginBottom = 0;
appearance.textLabelAttributes = @{NSFontAttributeName: DefaultTextLabelFont, NSForegroundColorAttributeName: DefaultLabelColor, NSParagraphStyleAttributeName: [NSMutableParagraphStyle qmui_paragraphStyleWithLineHeight: 22]};
appearance.detailTextLabelAttributes = @{NSFontAttributeName: DefaultDetailTextLabelFont, NSForegroundColorAttributeName: DefaultLabelColor, NSParagraphStyleAttributeName: [NSMutableParagraphStyle qmui_paragraphStyleWithLineHeight: 18]};
appearance.textLabelAttributes = @{NSFontAttributeName: UIFontBoldMake(16), NSParagraphStyleAttributeName: [NSMutableParagraphStyle qmui_paragraphStyleWithLineHeight:22 lineBreakMode:NSLineBreakByWordWrapping textAlignment:NSTextAlignmentCenter]};
appearance.detailTextLabelAttributes = @{NSFontAttributeName: UIFontBoldMake(12), NSParagraphStyleAttributeName: [NSMutableParagraphStyle qmui_paragraphStyleWithLineHeight:18 lineBreakMode:NSLineBreakByWordWrapping textAlignment:NSTextAlignmentCenter]};
}

@end
2 changes: 2 additions & 0 deletions QMUIKit/QMUIComponents/ToastView/QMUIToastView.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ typedef NS_ENUM(NSInteger, QMUIToastViewPosition) {
*
* 拓展性:`QMUIToastBackgroundView`和`QMUIToastContentView`是QMUI提供的默认的view,这两个view都可以通过appearance来修改样式,如果这两个view满足不了需求,那么也可以通过新建自定义的view来代替这两个view。另外,QMUI也提供了默认的toastAnimator来实现ToastView的显示和隐藏动画,如果需要重新定义一套动画,可以继承`QMUIToastAnimator`并且实现`QMUIToastAnimatorDelegate`中的协议就可以自定义自己的一套动画。
*
* 样式自定义:建议通过 tintColor 统一修改整个 toastView 的内容样式。当然你也可以单独修改 contentView.tintColor。默认情况下 QMUIToastView.tintColor = UIColorWhite。
*
* 建议使用`QMUIToastView`的时候,再封装一层,具体可以参考`QMUITips`这个类。
*
* @see QMUIToastBackgroundView
Expand Down
8 changes: 4 additions & 4 deletions QMUIKit/QMUIComponents/ToastView/QMUIToastView.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ - (instancetype)initWithView:(UIView *)view {
NSAssert(view, @"view不能为空");
if (self = [super initWithFrame:view.bounds]) {
_parentView = view;
[self commonInit];
[self didInitialize];
}
return self;
}
Expand All @@ -46,7 +46,9 @@ - (void)dealloc {
[self removeNotifications];
}

- (void)commonInit {
- (void)didInitialize {

self.tintColor = UIColorWhite;

self.toastPosition = QMUIToastViewPositionCenter;

Expand All @@ -59,8 +61,6 @@ - (void)commonInit {
self.backgroundColor = UIColorClear;
self.layer.allowsGroupOpacity = NO;

self.tintColor = UIColorWhite;

_maskView = [[UIView alloc] init];
self.maskView.backgroundColor = UIColorClear;
[self addSubview:self.maskView];
Expand Down
5 changes: 2 additions & 3 deletions QMUIKit/UIKitExtensions/UIView+QMUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ - (CAShapeLayer *)qmui_borderLayer {
@end


const CGFloat QMUIViewSelfSizingHeight = CGFLOAT_MAX - 1;
const CGFloat QMUIViewSelfSizingHeight = INFINITY;

@implementation UIView (QMUI_Layout)

Expand All @@ -472,8 +472,7 @@ + (void)load {
}

- (void)qmui_setFrame:(CGRect)frame {
// 特别的,对于 UIButton.titleLabel(也即 UIButtonLabel),它的 setFrame 里会将高度变成+inf,即便我们传的是 QMUIViewSelfSizingHeight,所以这里特殊处理一下
if (CGRectGetWidth(frame) > 0 && (CGRectGetHeight(frame) == QMUIViewSelfSizingHeight || (isinf(CGRectGetHeight(frame)) && [self isKindOfClass:[UILabel class]]))) {
if (CGRectGetWidth(frame) > 0 && isinf(CGRectGetHeight(frame))) {
CGFloat height = flat([self sizeThatFits:CGSizeMake(CGRectGetWidth(frame), CGFLOAT_MAX)].height);
frame = CGRectSetHeight(frame, height);
}
Expand Down

0 comments on commit 7e0f488

Please sign in to comment.