4
This commit is contained in:
25
Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.h
generated
Normal file
25
Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.h
generated
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// MJRefreshGifHeader.h
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by MJ Lee on 15/4/24.
|
||||
// Copyright (c) 2015年 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_include(<MJRefresh/MJRefreshStateHeader.h>)
|
||||
#import <MJRefresh/MJRefreshStateHeader.h>
|
||||
#else
|
||||
#import "MJRefreshStateHeader.h"
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MJRefreshGifHeader : MJRefreshStateHeader
|
||||
@property (weak, nonatomic, readonly) UIImageView *gifView;
|
||||
|
||||
/** 设置state状态下的动画图片images 动画持续时间duration*/
|
||||
- (instancetype)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state;
|
||||
- (instancetype)setImages:(NSArray *)images forState:(MJRefreshState)state;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
135
Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.m
generated
Normal file
135
Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.m
generated
Normal file
@@ -0,0 +1,135 @@
|
||||
//
|
||||
// MJRefreshGifHeader.m
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by MJ Lee on 15/4/24.
|
||||
// Copyright (c) 2015年 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MJRefreshGifHeader.h"
|
||||
#import "UIView+MJExtension.h"
|
||||
#import "UIScrollView+MJExtension.h"
|
||||
|
||||
@interface MJRefreshGifHeader()
|
||||
{
|
||||
__unsafe_unretained UIImageView *_gifView;
|
||||
}
|
||||
/** 所有状态对应的动画图片 */
|
||||
@property (strong, nonatomic) NSMutableDictionary *stateImages;
|
||||
/** 所有状态对应的动画时间 */
|
||||
@property (strong, nonatomic) NSMutableDictionary *stateDurations;
|
||||
@end
|
||||
|
||||
@implementation MJRefreshGifHeader
|
||||
#pragma mark - 懒加载
|
||||
- (UIImageView *)gifView
|
||||
{
|
||||
if (!_gifView) {
|
||||
UIImageView *gifView = [[UIImageView alloc] init];
|
||||
[self addSubview:_gifView = gifView];
|
||||
}
|
||||
return _gifView;
|
||||
}
|
||||
|
||||
- (NSMutableDictionary *)stateImages
|
||||
{
|
||||
if (!_stateImages) {
|
||||
self.stateImages = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return _stateImages;
|
||||
}
|
||||
|
||||
- (NSMutableDictionary *)stateDurations
|
||||
{
|
||||
if (!_stateDurations) {
|
||||
self.stateDurations = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return _stateDurations;
|
||||
}
|
||||
|
||||
#pragma mark - 公共方法
|
||||
- (instancetype)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state {
|
||||
if (images == nil) return self;
|
||||
|
||||
self.stateImages[@(state)] = images;
|
||||
self.stateDurations[@(state)] = @(duration);
|
||||
|
||||
/* 根据图片设置控件的高度 */
|
||||
UIImage *image = [images firstObject];
|
||||
if (image.size.height > self.mj_h) {
|
||||
self.mj_h = image.size.height;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)setImages:(NSArray *)images forState:(MJRefreshState)state
|
||||
{
|
||||
return [self setImages:images duration:images.count * 0.1 forState:state];
|
||||
}
|
||||
|
||||
#pragma mark - 实现父类的方法
|
||||
- (void)prepare
|
||||
{
|
||||
[super prepare];
|
||||
|
||||
// 初始化间距
|
||||
self.labelLeftInset = 20;
|
||||
}
|
||||
|
||||
- (void)setPullingPercent:(CGFloat)pullingPercent
|
||||
{
|
||||
[super setPullingPercent:pullingPercent];
|
||||
NSArray *images = self.stateImages[@(MJRefreshStateIdle)];
|
||||
if (self.state != MJRefreshStateIdle || images.count == 0) return;
|
||||
// 停止动画
|
||||
[self.gifView stopAnimating];
|
||||
// 设置当前需要显示的图片
|
||||
NSUInteger index = images.count * pullingPercent;
|
||||
if (index >= images.count) index = images.count - 1;
|
||||
self.gifView.image = images[index];
|
||||
}
|
||||
|
||||
- (void)placeSubviews
|
||||
{
|
||||
[super placeSubviews];
|
||||
|
||||
if (self.gifView.constraints.count) return;
|
||||
|
||||
self.gifView.frame = self.bounds;
|
||||
if (self.stateLabel.hidden && self.lastUpdatedTimeLabel.hidden) {
|
||||
self.gifView.contentMode = UIViewContentModeCenter;
|
||||
} else {
|
||||
self.gifView.contentMode = UIViewContentModeRight;
|
||||
|
||||
CGFloat stateWidth = self.stateLabel.mj_textWidth;
|
||||
CGFloat timeWidth = 0.0;
|
||||
if (!self.lastUpdatedTimeLabel.hidden) {
|
||||
timeWidth = self.lastUpdatedTimeLabel.mj_textWidth;
|
||||
}
|
||||
CGFloat textWidth = MAX(stateWidth, timeWidth);
|
||||
self.gifView.mj_w = self.mj_w * 0.5 - textWidth * 0.5 - self.labelLeftInset;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setState:(MJRefreshState)state
|
||||
{
|
||||
MJRefreshCheckState
|
||||
|
||||
// 根据状态做事情
|
||||
if (state == MJRefreshStatePulling || state == MJRefreshStateRefreshing) {
|
||||
NSArray *images = self.stateImages[@(state)];
|
||||
if (images.count == 0) return;
|
||||
|
||||
[self.gifView stopAnimating];
|
||||
if (images.count == 1) { // 单张图片
|
||||
self.gifView.image = [images lastObject];
|
||||
} else { // 多张图片
|
||||
self.gifView.animationImages = images;
|
||||
self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue];
|
||||
[self.gifView startAnimating];
|
||||
}
|
||||
} else if (state == MJRefreshStateIdle) {
|
||||
[self.gifView stopAnimating];
|
||||
}
|
||||
}
|
||||
@end
|
||||
26
Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.h
generated
Normal file
26
Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.h
generated
Normal file
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// MJRefreshNormalHeader.h
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by MJ Lee on 15/4/24.
|
||||
// Copyright (c) 2015年 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_include(<MJRefresh/MJRefreshStateHeader.h>)
|
||||
#import <MJRefresh/MJRefreshStateHeader.h>
|
||||
#else
|
||||
#import "MJRefreshStateHeader.h"
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MJRefreshNormalHeader : MJRefreshStateHeader
|
||||
@property (weak, nonatomic, readonly) UIImageView *arrowView;
|
||||
@property (weak, nonatomic, readonly) UIActivityIndicatorView *loadingView;
|
||||
|
||||
|
||||
/** 菊花的样式 */
|
||||
@property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle MJRefreshDeprecated("first deprecated in 3.2.2 - Use `loadingView` property");
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
137
Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.m
generated
Normal file
137
Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.m
generated
Normal file
@@ -0,0 +1,137 @@
|
||||
//
|
||||
// MJRefreshNormalHeader.m
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by MJ Lee on 15/4/24.
|
||||
// Copyright (c) 2015年 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MJRefreshNormalHeader.h"
|
||||
#import "NSBundle+MJRefresh.h"
|
||||
#import "UIScrollView+MJRefresh.h"
|
||||
#import "UIView+MJExtension.h"
|
||||
|
||||
@interface MJRefreshNormalHeader()
|
||||
{
|
||||
__unsafe_unretained UIImageView *_arrowView;
|
||||
}
|
||||
@property (weak, nonatomic) UIActivityIndicatorView *loadingView;
|
||||
@end
|
||||
|
||||
@implementation MJRefreshNormalHeader
|
||||
#pragma mark - 懒加载子控件
|
||||
- (UIImageView *)arrowView
|
||||
{
|
||||
if (!_arrowView) {
|
||||
UIImageView *arrowView = [[UIImageView alloc] initWithImage:[NSBundle mj_arrowImage]];
|
||||
[self addSubview:_arrowView = arrowView];
|
||||
}
|
||||
return _arrowView;
|
||||
}
|
||||
|
||||
- (UIActivityIndicatorView *)loadingView
|
||||
{
|
||||
if (!_loadingView) {
|
||||
UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:_activityIndicatorViewStyle];
|
||||
loadingView.hidesWhenStopped = YES;
|
||||
[self addSubview:_loadingView = loadingView];
|
||||
}
|
||||
return _loadingView;
|
||||
}
|
||||
|
||||
#pragma mark - 公共方法
|
||||
- (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle
|
||||
{
|
||||
_activityIndicatorViewStyle = activityIndicatorViewStyle;
|
||||
|
||||
[self.loadingView removeFromSuperview];
|
||||
self.loadingView = nil;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
#pragma mark - 重写父类的方法
|
||||
- (void)prepare
|
||||
{
|
||||
[super prepare];
|
||||
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
|
||||
if (@available(iOS 13.0, *)) {
|
||||
_activityIndicatorViewStyle = UIActivityIndicatorViewStyleMedium;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
_activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
|
||||
}
|
||||
|
||||
- (void)placeSubviews
|
||||
{
|
||||
[super placeSubviews];
|
||||
|
||||
// 箭头的中心点
|
||||
CGFloat arrowCenterX = self.mj_w * 0.5;
|
||||
if (!self.stateLabel.hidden) {
|
||||
CGFloat stateWidth = self.stateLabel.mj_textWidth;
|
||||
CGFloat timeWidth = 0.0;
|
||||
if (!self.lastUpdatedTimeLabel.hidden) {
|
||||
timeWidth = self.lastUpdatedTimeLabel.mj_textWidth;
|
||||
}
|
||||
CGFloat textWidth = MAX(stateWidth, timeWidth);
|
||||
arrowCenterX -= textWidth / 2 + self.labelLeftInset;
|
||||
}
|
||||
CGFloat arrowCenterY = self.mj_h * 0.5;
|
||||
CGPoint arrowCenter = CGPointMake(arrowCenterX, arrowCenterY);
|
||||
|
||||
// 箭头
|
||||
if (self.arrowView.constraints.count == 0) {
|
||||
self.arrowView.mj_size = self.arrowView.image.size;
|
||||
self.arrowView.center = arrowCenter;
|
||||
}
|
||||
|
||||
// 圈圈
|
||||
if (self.loadingView.constraints.count == 0) {
|
||||
self.loadingView.center = arrowCenter;
|
||||
}
|
||||
|
||||
self.arrowView.tintColor = self.stateLabel.textColor;
|
||||
}
|
||||
|
||||
- (void)setState:(MJRefreshState)state
|
||||
{
|
||||
MJRefreshCheckState
|
||||
|
||||
// 根据状态做事情
|
||||
if (state == MJRefreshStateIdle) {
|
||||
if (oldState == MJRefreshStateRefreshing) {
|
||||
self.arrowView.transform = CGAffineTransformIdentity;
|
||||
|
||||
[UIView animateWithDuration:self.slowAnimationDuration animations:^{
|
||||
self.loadingView.alpha = 0.0;
|
||||
} completion:^(BOOL finished) {
|
||||
// 如果执行完动画发现不是idle状态,就直接返回,进入其他状态
|
||||
if (self.state != MJRefreshStateIdle) return;
|
||||
|
||||
self.loadingView.alpha = 1.0;
|
||||
[self.loadingView stopAnimating];
|
||||
self.arrowView.hidden = NO;
|
||||
}];
|
||||
} else {
|
||||
[self.loadingView stopAnimating];
|
||||
self.arrowView.hidden = NO;
|
||||
[UIView animateWithDuration:self.fastAnimationDuration animations:^{
|
||||
self.arrowView.transform = CGAffineTransformIdentity;
|
||||
}];
|
||||
}
|
||||
} else if (state == MJRefreshStatePulling) {
|
||||
[self.loadingView stopAnimating];
|
||||
self.arrowView.hidden = NO;
|
||||
[UIView animateWithDuration:self.fastAnimationDuration animations:^{
|
||||
self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI);
|
||||
}];
|
||||
} else if (state == MJRefreshStateRefreshing) {
|
||||
self.loadingView.alpha = 1.0; // 防止refreshing -> idle的动画完毕动作没有被执行
|
||||
[self.loadingView startAnimating];
|
||||
self.arrowView.hidden = YES;
|
||||
}
|
||||
}
|
||||
@end
|
||||
39
Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshStateHeader.h
generated
Normal file
39
Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshStateHeader.h
generated
Normal file
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// MJRefreshStateHeader.h
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by MJ Lee on 15/4/24.
|
||||
// Copyright (c) 2015年 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_include(<MJRefresh/MJRefreshHeader.h>)
|
||||
#import <MJRefresh/MJRefreshHeader.h>
|
||||
#else
|
||||
#import "MJRefreshHeader.h"
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MJRefreshStateHeader : MJRefreshHeader
|
||||
#pragma mark - 刷新时间相关
|
||||
/** 利用这个block来决定显示的更新时间文字 */
|
||||
@property (copy, nonatomic, nullable) NSString *(^lastUpdatedTimeText)(NSDate * _Nullable lastUpdatedTime);
|
||||
/** 显示上一次刷新时间的label */
|
||||
@property (weak, nonatomic, readonly) UILabel *lastUpdatedTimeLabel;
|
||||
|
||||
#pragma mark - 状态相关
|
||||
/** 文字距离圈圈、箭头的距离 */
|
||||
@property (assign, nonatomic) CGFloat labelLeftInset;
|
||||
/** 显示刷新状态的label */
|
||||
@property (weak, nonatomic, readonly) UILabel *stateLabel;
|
||||
/** 设置state状态下的文字 */
|
||||
- (instancetype)setTitle:(NSString *)title forState:(MJRefreshState)state;
|
||||
@end
|
||||
|
||||
@interface MJRefreshStateHeader (ChainingGrammar)
|
||||
|
||||
- (instancetype)modifyLastUpdatedTimeText:(NSString * (^)(NSDate * _Nullable lastUpdatedTime))handler;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
191
Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshStateHeader.m
generated
Normal file
191
Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshStateHeader.m
generated
Normal file
@@ -0,0 +1,191 @@
|
||||
//
|
||||
// MJRefreshStateHeader.m
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by MJ Lee on 15/4/24.
|
||||
// Copyright (c) 2015年 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MJRefreshStateHeader.h"
|
||||
#import "MJRefreshConst.h"
|
||||
#import "NSBundle+MJRefresh.h"
|
||||
#import "UIView+MJExtension.h"
|
||||
#import "UIScrollView+MJExtension.h"
|
||||
|
||||
@interface MJRefreshStateHeader()
|
||||
{
|
||||
/** 显示上一次刷新时间的label */
|
||||
__unsafe_unretained UILabel *_lastUpdatedTimeLabel;
|
||||
/** 显示刷新状态的label */
|
||||
__unsafe_unretained UILabel *_stateLabel;
|
||||
}
|
||||
/** 所有状态对应的文字 */
|
||||
@property (strong, nonatomic) NSMutableDictionary *stateTitles;
|
||||
@end
|
||||
|
||||
@implementation MJRefreshStateHeader
|
||||
#pragma mark - 懒加载
|
||||
- (NSMutableDictionary *)stateTitles
|
||||
{
|
||||
if (!_stateTitles) {
|
||||
self.stateTitles = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return _stateTitles;
|
||||
}
|
||||
|
||||
- (UILabel *)stateLabel
|
||||
{
|
||||
if (!_stateLabel) {
|
||||
[self addSubview:_stateLabel = [UILabel mj_label]];
|
||||
}
|
||||
return _stateLabel;
|
||||
}
|
||||
|
||||
- (UILabel *)lastUpdatedTimeLabel
|
||||
{
|
||||
if (!_lastUpdatedTimeLabel) {
|
||||
[self addSubview:_lastUpdatedTimeLabel = [UILabel mj_label]];
|
||||
}
|
||||
return _lastUpdatedTimeLabel;
|
||||
}
|
||||
|
||||
- (void)setLastUpdatedTimeText:(NSString * _Nonnull (^)(NSDate * _Nullable))lastUpdatedTimeText{
|
||||
_lastUpdatedTimeText = lastUpdatedTimeText;
|
||||
// 重新设置key(重新显示时间)
|
||||
self.lastUpdatedTimeKey = self.lastUpdatedTimeKey;
|
||||
}
|
||||
|
||||
#pragma mark - 公共方法
|
||||
- (instancetype)setTitle:(NSString *)title forState:(MJRefreshState)state
|
||||
{
|
||||
if (title == nil) return self;
|
||||
self.stateTitles[@(state)] = title;
|
||||
self.stateLabel.text = self.stateTitles[@(self.state)];
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark key的处理
|
||||
- (void)setLastUpdatedTimeKey:(NSString *)lastUpdatedTimeKey
|
||||
{
|
||||
[super setLastUpdatedTimeKey:lastUpdatedTimeKey];
|
||||
|
||||
// 如果label隐藏了,就不用再处理
|
||||
if (self.lastUpdatedTimeLabel.hidden) return;
|
||||
|
||||
NSDate *lastUpdatedTime = [[NSUserDefaults standardUserDefaults] objectForKey:lastUpdatedTimeKey];
|
||||
|
||||
// 如果有block
|
||||
if (self.lastUpdatedTimeText) {
|
||||
self.lastUpdatedTimeLabel.text = self.lastUpdatedTimeText(lastUpdatedTime);
|
||||
return;
|
||||
}
|
||||
|
||||
if (lastUpdatedTime) {
|
||||
// 1.获得年月日
|
||||
NSCalendar *calendar = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian];
|
||||
NSUInteger unitFlags = NSCalendarUnitYear| NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute;
|
||||
NSDateComponents *cmp1 = [calendar components:unitFlags fromDate:lastUpdatedTime];
|
||||
NSDateComponents *cmp2 = [calendar components:unitFlags fromDate:[NSDate date]];
|
||||
|
||||
// 2.格式化日期
|
||||
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
|
||||
BOOL isToday = NO;
|
||||
if ([cmp1 day] == [cmp2 day]) { // 今天
|
||||
formatter.dateFormat = @" HH:mm";
|
||||
isToday = YES;
|
||||
} else if ([cmp1 year] == [cmp2 year]) { // 今年
|
||||
formatter.dateFormat = @"MM-dd HH:mm";
|
||||
} else {
|
||||
formatter.dateFormat = @"yyyy-MM-dd HH:mm";
|
||||
}
|
||||
NSString *time = [formatter stringFromDate:lastUpdatedTime];
|
||||
|
||||
// 3.显示日期
|
||||
self.lastUpdatedTimeLabel.text = [NSString stringWithFormat:@"%@%@%@",
|
||||
[NSBundle mj_localizedStringForKey:MJRefreshHeaderLastTimeText],
|
||||
isToday ? [NSBundle mj_localizedStringForKey:MJRefreshHeaderDateTodayText] : @"",
|
||||
time];
|
||||
} else {
|
||||
self.lastUpdatedTimeLabel.text = [NSString stringWithFormat:@"%@%@",
|
||||
[NSBundle mj_localizedStringForKey:MJRefreshHeaderLastTimeText],
|
||||
[NSBundle mj_localizedStringForKey:MJRefreshHeaderNoneLastDateText]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)textConfiguration {
|
||||
// 初始化文字
|
||||
[self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshHeaderIdleText] forState:MJRefreshStateIdle];
|
||||
[self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshHeaderPullingText] forState:MJRefreshStatePulling];
|
||||
[self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshHeaderRefreshingText] forState:MJRefreshStateRefreshing];
|
||||
self.lastUpdatedTimeKey = MJRefreshHeaderLastUpdatedTimeKey;
|
||||
}
|
||||
|
||||
#pragma mark - 覆盖父类的方法
|
||||
- (void)prepare
|
||||
{
|
||||
[super prepare];
|
||||
|
||||
// 初始化间距
|
||||
self.labelLeftInset = MJRefreshLabelLeftInset;
|
||||
[self textConfiguration];
|
||||
}
|
||||
|
||||
- (void)i18nDidChange {
|
||||
[self textConfiguration];
|
||||
|
||||
[super i18nDidChange];
|
||||
}
|
||||
|
||||
- (void)placeSubviews
|
||||
{
|
||||
[super placeSubviews];
|
||||
|
||||
if (self.stateLabel.hidden) return;
|
||||
|
||||
BOOL noConstrainsOnStatusLabel = self.stateLabel.constraints.count == 0;
|
||||
|
||||
if (self.lastUpdatedTimeLabel.hidden) {
|
||||
// 状态
|
||||
if (noConstrainsOnStatusLabel) self.stateLabel.frame = self.bounds;
|
||||
} else {
|
||||
CGFloat stateLabelH = self.mj_h * 0.5;
|
||||
// 状态
|
||||
if (noConstrainsOnStatusLabel) {
|
||||
self.stateLabel.mj_x = 0;
|
||||
self.stateLabel.mj_y = 0;
|
||||
self.stateLabel.mj_w = self.mj_w;
|
||||
self.stateLabel.mj_h = stateLabelH;
|
||||
}
|
||||
|
||||
// 更新时间
|
||||
if (self.lastUpdatedTimeLabel.constraints.count == 0) {
|
||||
self.lastUpdatedTimeLabel.mj_x = 0;
|
||||
self.lastUpdatedTimeLabel.mj_y = stateLabelH;
|
||||
self.lastUpdatedTimeLabel.mj_w = self.mj_w;
|
||||
self.lastUpdatedTimeLabel.mj_h = self.mj_h - self.lastUpdatedTimeLabel.mj_y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setState:(MJRefreshState)state
|
||||
{
|
||||
MJRefreshCheckState
|
||||
|
||||
// 设置状态文字
|
||||
self.stateLabel.text = self.stateTitles[@(state)];
|
||||
|
||||
// 重新设置key(重新显示时间)
|
||||
self.lastUpdatedTimeKey = self.lastUpdatedTimeKey;
|
||||
}
|
||||
@end
|
||||
|
||||
#pragma mark - <<< 为 Swift 扩展链式语法 >>> -
|
||||
@implementation MJRefreshStateHeader (ChainingGrammar)
|
||||
|
||||
- (instancetype)modifyLastUpdatedTimeText:(NSString * _Nonnull (^)(NSDate * _Nullable))handler {
|
||||
self.lastUpdatedTimeText = handler;
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user