4
This commit is contained in:
25
Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.h
generated
Normal file
25
Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.h
generated
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// MJRefreshAutoGifFooter.h
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by MJ Lee on 15/4/24.
|
||||
// Copyright (c) 2015年 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_include(<MJRefresh/MJRefreshAutoStateFooter.h>)
|
||||
#import <MJRefresh/MJRefreshAutoStateFooter.h>
|
||||
#else
|
||||
#import "MJRefreshAutoStateFooter.h"
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MJRefreshAutoGifFooter : MJRefreshAutoStateFooter
|
||||
@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
|
||||
121
Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.m
generated
Normal file
121
Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.m
generated
Normal file
@@ -0,0 +1,121 @@
|
||||
//
|
||||
// MJRefreshAutoGifFooter.m
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by MJ Lee on 15/4/24.
|
||||
// Copyright (c) 2015年 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MJRefreshAutoGifFooter.h"
|
||||
#import "NSBundle+MJRefresh.h"
|
||||
#import "UIView+MJExtension.h"
|
||||
#import "UIScrollView+MJExtension.h"
|
||||
#import "UIScrollView+MJRefresh.h"
|
||||
|
||||
@interface MJRefreshAutoGifFooter()
|
||||
{
|
||||
__unsafe_unretained UIImageView *_gifView;
|
||||
}
|
||||
/** 所有状态对应的动画图片 */
|
||||
@property (strong, nonatomic) NSMutableDictionary *stateImages;
|
||||
/** 所有状态对应的动画时间 */
|
||||
@property (strong, nonatomic) NSMutableDictionary *stateDurations;
|
||||
@end
|
||||
|
||||
@implementation MJRefreshAutoGifFooter
|
||||
#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)placeSubviews
|
||||
{
|
||||
[super placeSubviews];
|
||||
|
||||
if (self.gifView.constraints.count) return;
|
||||
|
||||
self.gifView.frame = self.bounds;
|
||||
if (self.isRefreshingTitleHidden) {
|
||||
self.gifView.contentMode = UIViewContentModeCenter;
|
||||
} else {
|
||||
self.gifView.contentMode = UIViewContentModeRight;
|
||||
self.gifView.mj_w = self.mj_w * 0.5 - self.labelLeftInset - self.stateLabel.mj_textWidth * 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setState:(MJRefreshState)state
|
||||
{
|
||||
MJRefreshCheckState
|
||||
|
||||
// 根据状态做事情
|
||||
if (state == MJRefreshStateRefreshing) {
|
||||
NSArray *images = self.stateImages[@(state)];
|
||||
if (images.count == 0) return;
|
||||
[self.gifView stopAnimating];
|
||||
|
||||
self.gifView.hidden = NO;
|
||||
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 == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) {
|
||||
[self.gifView stopAnimating];
|
||||
self.gifView.hidden = YES;
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
25
Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.h
generated
Normal file
25
Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.h
generated
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// MJRefreshAutoNormalFooter.h
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by MJ Lee on 15/4/24.
|
||||
// Copyright (c) 2015年 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_include(<MJRefresh/MJRefreshAutoStateFooter.h>)
|
||||
#import <MJRefresh/MJRefreshAutoStateFooter.h>
|
||||
#else
|
||||
#import "MJRefreshAutoStateFooter.h"
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MJRefreshAutoNormalFooter : MJRefreshAutoStateFooter
|
||||
@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
|
||||
81
Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.m
generated
Normal file
81
Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.m
generated
Normal file
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// MJRefreshAutoNormalFooter.m
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by MJ Lee on 15/4/24.
|
||||
// Copyright (c) 2015年 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MJRefreshAutoNormalFooter.h"
|
||||
#import "NSBundle+MJRefresh.h"
|
||||
#import "UIView+MJExtension.h"
|
||||
#import "UIScrollView+MJExtension.h"
|
||||
#import "UIScrollView+MJRefresh.h"
|
||||
|
||||
@interface MJRefreshAutoNormalFooter()
|
||||
@property (weak, nonatomic) UIActivityIndicatorView *loadingView;
|
||||
@end
|
||||
|
||||
@implementation MJRefreshAutoNormalFooter
|
||||
#pragma mark - 懒加载子控件
|
||||
- (UIActivityIndicatorView *)loadingView
|
||||
{
|
||||
if (!_loadingView) {
|
||||
UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:_activityIndicatorViewStyle];
|
||||
loadingView.hidesWhenStopped = YES;
|
||||
[self addSubview:_loadingView = loadingView];
|
||||
}
|
||||
return _loadingView;
|
||||
}
|
||||
|
||||
- (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];
|
||||
|
||||
if (self.loadingView.constraints.count) return;
|
||||
|
||||
// 圈圈
|
||||
CGFloat loadingCenterX = self.mj_w * 0.5;
|
||||
if (!self.isRefreshingTitleHidden) {
|
||||
loadingCenterX -= self.stateLabel.mj_textWidth * 0.5 + self.labelLeftInset;
|
||||
}
|
||||
CGFloat loadingCenterY = self.mj_h * 0.5;
|
||||
self.loadingView.center = CGPointMake(loadingCenterX, loadingCenterY);
|
||||
}
|
||||
|
||||
- (void)setState:(MJRefreshState)state
|
||||
{
|
||||
MJRefreshCheckState
|
||||
|
||||
// 根据状态做事情
|
||||
if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) {
|
||||
[self.loadingView stopAnimating];
|
||||
} else if (state == MJRefreshStateRefreshing) {
|
||||
[self.loadingView startAnimating];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
30
Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.h
generated
Normal file
30
Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.h
generated
Normal file
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// MJRefreshAutoStateFooter.h
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by MJ Lee on 15/6/13.
|
||||
// Copyright © 2015年 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_include(<MJRefresh/MJRefreshAutoFooter.h>)
|
||||
#import <MJRefresh/MJRefreshAutoFooter.h>
|
||||
#else
|
||||
#import "MJRefreshAutoFooter.h"
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MJRefreshAutoStateFooter : MJRefreshAutoFooter
|
||||
/** 文字距离圈圈、箭头的距离 */
|
||||
@property (assign, nonatomic) CGFloat labelLeftInset;
|
||||
/** 显示刷新状态的label */
|
||||
@property (weak, nonatomic, readonly) UILabel *stateLabel;
|
||||
|
||||
/** 设置state状态下的文字 */
|
||||
- (instancetype)setTitle:(NSString *)title forState:(MJRefreshState)state;
|
||||
|
||||
/** 隐藏刷新状态的文字 */
|
||||
@property (assign, nonatomic, getter=isRefreshingTitleHidden) BOOL refreshingTitleHidden;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
119
Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.m
generated
Normal file
119
Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.m
generated
Normal file
@@ -0,0 +1,119 @@
|
||||
//
|
||||
// MJRefreshAutoStateFooter.m
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by MJ Lee on 15/6/13.
|
||||
// Copyright © 2015年 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MJRefreshAutoStateFooter.h"
|
||||
#import "NSBundle+MJRefresh.h"
|
||||
|
||||
@interface MJRefreshAutoFooter (TapTriggerFix)
|
||||
|
||||
- (void)beginRefreshingWithoutValidation;
|
||||
@end
|
||||
|
||||
|
||||
@implementation MJRefreshAutoFooter (TapTriggerFix)
|
||||
|
||||
- (void)beginRefreshingWithoutValidation {
|
||||
[super beginRefreshing];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface MJRefreshAutoStateFooter()
|
||||
{
|
||||
/** 显示刷新状态的label */
|
||||
__unsafe_unretained UILabel *_stateLabel;
|
||||
}
|
||||
/** 所有状态对应的文字 */
|
||||
@property (strong, nonatomic) NSMutableDictionary *stateTitles;
|
||||
@end
|
||||
|
||||
@implementation MJRefreshAutoStateFooter
|
||||
#pragma mark - 懒加载
|
||||
- (NSMutableDictionary *)stateTitles
|
||||
{
|
||||
if (!_stateTitles) {
|
||||
self.stateTitles = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return _stateTitles;
|
||||
}
|
||||
|
||||
- (UILabel *)stateLabel
|
||||
{
|
||||
if (!_stateLabel) {
|
||||
[self addSubview:_stateLabel = [UILabel mj_label]];
|
||||
}
|
||||
return _stateLabel;
|
||||
}
|
||||
|
||||
#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 - 私有方法
|
||||
- (void)stateLabelClick
|
||||
{
|
||||
if (self.state == MJRefreshStateIdle) {
|
||||
[super beginRefreshingWithoutValidation];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)textConfiguration {
|
||||
// 初始化文字
|
||||
[self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshAutoFooterIdleText] forState:MJRefreshStateIdle];
|
||||
[self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshAutoFooterRefreshingText] forState:MJRefreshStateRefreshing];
|
||||
[self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshAutoFooterNoMoreDataText] forState:MJRefreshStateNoMoreData];
|
||||
}
|
||||
|
||||
#pragma mark - 重写父类的方法
|
||||
- (void)prepare
|
||||
{
|
||||
[super prepare];
|
||||
|
||||
// 初始化间距
|
||||
self.labelLeftInset = MJRefreshLabelLeftInset;
|
||||
|
||||
[self textConfiguration];
|
||||
|
||||
// 监听label
|
||||
self.stateLabel.userInteractionEnabled = YES;
|
||||
[self.stateLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(stateLabelClick)]];
|
||||
}
|
||||
|
||||
- (void)i18nDidChange {
|
||||
[self textConfiguration];
|
||||
|
||||
[super i18nDidChange];
|
||||
}
|
||||
|
||||
|
||||
- (void)placeSubviews
|
||||
{
|
||||
[super placeSubviews];
|
||||
|
||||
if (self.stateLabel.constraints.count) return;
|
||||
|
||||
// 状态标签
|
||||
self.stateLabel.frame = self.bounds;
|
||||
}
|
||||
|
||||
- (void)setState:(MJRefreshState)state
|
||||
{
|
||||
MJRefreshCheckState
|
||||
|
||||
if (self.isRefreshingTitleHidden && state == MJRefreshStateRefreshing) {
|
||||
self.stateLabel.text = nil;
|
||||
} else {
|
||||
self.stateLabel.text = self.stateTitles[@(state)];
|
||||
}
|
||||
}
|
||||
@end
|
||||
25
Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.h
generated
Normal file
25
Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.h
generated
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// MJRefreshBackGifFooter.h
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by MJ Lee on 15/4/24.
|
||||
// Copyright (c) 2015年 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_include(<MJRefresh/MJRefreshBackStateFooter.h>)
|
||||
#import <MJRefresh/MJRefreshBackStateFooter.h>
|
||||
#else
|
||||
#import "MJRefreshBackStateFooter.h"
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MJRefreshBackGifFooter : MJRefreshBackStateFooter
|
||||
@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
|
||||
132
Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.m
generated
Normal file
132
Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.m
generated
Normal file
@@ -0,0 +1,132 @@
|
||||
//
|
||||
// MJRefreshBackGifFooter.m
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by MJ Lee on 15/4/24.
|
||||
// Copyright (c) 2015年 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MJRefreshBackGifFooter.h"
|
||||
#import "NSBundle+MJRefresh.h"
|
||||
#import "UIView+MJExtension.h"
|
||||
#import "UIScrollView+MJExtension.h"
|
||||
#import "UIScrollView+MJRefresh.h"
|
||||
|
||||
@interface MJRefreshBackGifFooter()
|
||||
{
|
||||
__unsafe_unretained UIImageView *_gifView;
|
||||
}
|
||||
/** 所有状态对应的动画图片 */
|
||||
@property (strong, nonatomic) NSMutableDictionary *stateImages;
|
||||
/** 所有状态对应的动画时间 */
|
||||
@property (strong, nonatomic) NSMutableDictionary *stateDurations;
|
||||
@end
|
||||
|
||||
@implementation MJRefreshBackGifFooter
|
||||
#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.gifView.contentMode = UIViewContentModeCenter;
|
||||
} else {
|
||||
self.gifView.contentMode = UIViewContentModeRight;
|
||||
self.gifView.mj_w = self.mj_w * 0.5 - self.labelLeftInset - self.stateLabel.mj_textWidth * 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setState:(MJRefreshState)state
|
||||
{
|
||||
MJRefreshCheckState
|
||||
|
||||
// 根据状态做事情
|
||||
if (state == MJRefreshStatePulling || state == MJRefreshStateRefreshing) {
|
||||
NSArray *images = self.stateImages[@(state)];
|
||||
if (images.count == 0) return;
|
||||
|
||||
self.gifView.hidden = NO;
|
||||
[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.hidden = NO;
|
||||
} else if (state == MJRefreshStateNoMoreData) {
|
||||
self.gifView.hidden = YES;
|
||||
}
|
||||
}
|
||||
@end
|
||||
25
Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.h
generated
Normal file
25
Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.h
generated
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// MJRefreshBackNormalFooter.h
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by MJ Lee on 15/4/24.
|
||||
// Copyright (c) 2015年 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_include(<MJRefresh/MJRefreshBackStateFooter.h>)
|
||||
#import <MJRefresh/MJRefreshBackStateFooter.h>
|
||||
#else
|
||||
#import "MJRefreshBackStateFooter.h"
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MJRefreshBackNormalFooter : MJRefreshBackStateFooter
|
||||
@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
|
||||
132
Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.m
generated
Normal file
132
Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.m
generated
Normal file
@@ -0,0 +1,132 @@
|
||||
//
|
||||
// MJRefreshBackNormalFooter.m
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by MJ Lee on 15/4/24.
|
||||
// Copyright (c) 2015年 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MJRefreshBackNormalFooter.h"
|
||||
#import "NSBundle+MJRefresh.h"
|
||||
#import "UIView+MJExtension.h"
|
||||
|
||||
@interface MJRefreshBackNormalFooter()
|
||||
{
|
||||
__unsafe_unretained UIImageView *_arrowView;
|
||||
}
|
||||
@property (weak, nonatomic) UIActivityIndicatorView *loadingView;
|
||||
@end
|
||||
|
||||
@implementation MJRefreshBackNormalFooter
|
||||
#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;
|
||||
}
|
||||
|
||||
- (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) {
|
||||
arrowCenterX -= self.labelLeftInset + self.stateLabel.mj_textWidth * 0.5;
|
||||
}
|
||||
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 = CGAffineTransformMakeRotation(0.000001 - M_PI);
|
||||
[UIView animateWithDuration:self.slowAnimationDuration animations:^{
|
||||
self.loadingView.alpha = 0.0;
|
||||
} completion:^(BOOL finished) {
|
||||
// 防止动画结束后,状态已经不是MJRefreshStateIdle
|
||||
if (self.state != MJRefreshStateIdle) return;
|
||||
|
||||
self.loadingView.alpha = 1.0;
|
||||
[self.loadingView stopAnimating];
|
||||
|
||||
self.arrowView.hidden = NO;
|
||||
}];
|
||||
} else {
|
||||
self.arrowView.hidden = NO;
|
||||
[self.loadingView stopAnimating];
|
||||
[UIView animateWithDuration:self.fastAnimationDuration animations:^{
|
||||
self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI);
|
||||
}];
|
||||
}
|
||||
} else if (state == MJRefreshStatePulling) {
|
||||
self.arrowView.hidden = NO;
|
||||
[self.loadingView stopAnimating];
|
||||
[UIView animateWithDuration:self.fastAnimationDuration animations:^{
|
||||
self.arrowView.transform = CGAffineTransformIdentity;
|
||||
}];
|
||||
} else if (state == MJRefreshStateRefreshing) {
|
||||
self.arrowView.hidden = YES;
|
||||
[self.loadingView startAnimating];
|
||||
} else if (state == MJRefreshStateNoMoreData) {
|
||||
self.arrowView.hidden = YES;
|
||||
[self.loadingView stopAnimating];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
29
Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.h
generated
Normal file
29
Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.h
generated
Normal file
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// MJRefreshBackStateFooter.h
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by MJ Lee on 15/6/13.
|
||||
// Copyright © 2015年 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_include(<MJRefresh/MJRefreshBackFooter.h>)
|
||||
#import <MJRefresh/MJRefreshBackFooter.h>
|
||||
#else
|
||||
#import "MJRefreshBackFooter.h"
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MJRefreshBackStateFooter : MJRefreshBackFooter
|
||||
/** 文字距离圈圈、箭头的距离 */
|
||||
@property (assign, nonatomic) CGFloat labelLeftInset;
|
||||
/** 显示刷新状态的label */
|
||||
@property (weak, nonatomic, readonly) UILabel *stateLabel;
|
||||
/** 设置state状态下的文字 */
|
||||
- (instancetype)setTitle:(NSString *)title forState:(MJRefreshState)state;
|
||||
|
||||
/** 获取state状态下的title */
|
||||
- (NSString *)titleForState:(MJRefreshState)state;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
93
Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.m
generated
Normal file
93
Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.m
generated
Normal file
@@ -0,0 +1,93 @@
|
||||
//
|
||||
// MJRefreshBackStateFooter.m
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by MJ Lee on 15/6/13.
|
||||
// Copyright © 2015年 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MJRefreshBackStateFooter.h"
|
||||
#import "NSBundle+MJRefresh.h"
|
||||
|
||||
@interface MJRefreshBackStateFooter()
|
||||
{
|
||||
/** 显示刷新状态的label */
|
||||
__unsafe_unretained UILabel *_stateLabel;
|
||||
}
|
||||
/** 所有状态对应的文字 */
|
||||
@property (strong, nonatomic) NSMutableDictionary *stateTitles;
|
||||
@end
|
||||
|
||||
@implementation MJRefreshBackStateFooter
|
||||
#pragma mark - 懒加载
|
||||
- (NSMutableDictionary *)stateTitles
|
||||
{
|
||||
if (!_stateTitles) {
|
||||
self.stateTitles = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return _stateTitles;
|
||||
}
|
||||
|
||||
- (UILabel *)stateLabel
|
||||
{
|
||||
if (!_stateLabel) {
|
||||
[self addSubview:_stateLabel = [UILabel mj_label]];
|
||||
}
|
||||
return _stateLabel;
|
||||
}
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
- (NSString *)titleForState:(MJRefreshState)state {
|
||||
return self.stateTitles[@(state)];
|
||||
}
|
||||
|
||||
- (void)textConfiguration {
|
||||
// 初始化文字
|
||||
[self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterIdleText] forState:MJRefreshStateIdle];
|
||||
[self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterPullingText] forState:MJRefreshStatePulling];
|
||||
[self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterRefreshingText] forState:MJRefreshStateRefreshing];
|
||||
[self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterNoMoreDataText] forState:MJRefreshStateNoMoreData];
|
||||
}
|
||||
|
||||
#pragma mark - 重写父类的方法
|
||||
- (void)prepare
|
||||
{
|
||||
[super prepare];
|
||||
|
||||
// 初始化间距
|
||||
self.labelLeftInset = MJRefreshLabelLeftInset;
|
||||
[self textConfiguration];
|
||||
}
|
||||
|
||||
- (void)i18nDidChange {
|
||||
[self textConfiguration];
|
||||
|
||||
[super i18nDidChange];
|
||||
}
|
||||
|
||||
- (void)placeSubviews
|
||||
{
|
||||
[super placeSubviews];
|
||||
|
||||
if (self.stateLabel.constraints.count) return;
|
||||
|
||||
// 状态标签
|
||||
self.stateLabel.frame = self.bounds;
|
||||
}
|
||||
|
||||
- (void)setState:(MJRefreshState)state
|
||||
{
|
||||
MJRefreshCheckState
|
||||
|
||||
// 设置状态文字
|
||||
self.stateLabel.text = self.stateTitles[@(state)];
|
||||
}
|
||||
@end
|
||||
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
|
||||
23
Pods/MJRefresh/MJRefresh/Custom/Trailer/MJRefreshNormalTrailer.h
generated
Normal file
23
Pods/MJRefresh/MJRefresh/Custom/Trailer/MJRefreshNormalTrailer.h
generated
Normal file
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// MJRefreshNormalTrailer.h
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by kinarobin on 2020/5/3.
|
||||
// Copyright © 2020 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_include(<MJRefresh/MJRefreshStateTrailer.h>)
|
||||
#import <MJRefresh/MJRefreshStateTrailer.h>
|
||||
#else
|
||||
#import "MJRefreshStateTrailer.h"
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MJRefreshNormalTrailer : MJRefreshStateTrailer
|
||||
|
||||
@property (weak, nonatomic, readonly) UIImageView *arrowView;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
80
Pods/MJRefresh/MJRefresh/Custom/Trailer/MJRefreshNormalTrailer.m
generated
Normal file
80
Pods/MJRefresh/MJRefresh/Custom/Trailer/MJRefreshNormalTrailer.m
generated
Normal file
@@ -0,0 +1,80 @@
|
||||
//
|
||||
// MJRefreshNormalTrailer.m
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by kinarobin on 2020/5/3.
|
||||
// Copyright © 2020 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MJRefreshNormalTrailer.h"
|
||||
#import "NSBundle+MJRefresh.h"
|
||||
#import "UIView+MJExtension.h"
|
||||
|
||||
@interface MJRefreshNormalTrailer() {
|
||||
__unsafe_unretained UIImageView *_arrowView;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation MJRefreshNormalTrailer
|
||||
#pragma mark - 懒加载子控件
|
||||
- (UIImageView *)arrowView {
|
||||
if (!_arrowView) {
|
||||
UIImageView *arrowView = [[UIImageView alloc] initWithImage:[NSBundle mj_trailArrowImage]];
|
||||
[self addSubview:_arrowView = arrowView];
|
||||
}
|
||||
return _arrowView;
|
||||
}
|
||||
|
||||
- (void)placeSubviews {
|
||||
[super placeSubviews];
|
||||
|
||||
CGSize arrowSize = self.arrowView.image.size;
|
||||
// 箭头的中心点
|
||||
CGPoint selfCenter = CGPointMake(self.mj_w * 0.5, self.mj_h * 0.5);
|
||||
CGPoint arrowCenter = CGPointMake(arrowSize.width * 0.5 + 5, self.mj_h * 0.5);
|
||||
BOOL stateHidden = self.stateLabel.isHidden;
|
||||
|
||||
if (self.arrowView.constraints.count == 0) {
|
||||
self.arrowView.mj_size = self.arrowView.image.size;
|
||||
self.arrowView.center = stateHidden ? selfCenter : arrowCenter ;
|
||||
}
|
||||
self.arrowView.tintColor = self.stateLabel.textColor;
|
||||
|
||||
if (stateHidden) return;
|
||||
|
||||
BOOL noConstrainsOnStatusLabel = self.stateLabel.constraints.count == 0;
|
||||
CGFloat stateLabelW = ceil(self.stateLabel.font.pointSize);
|
||||
// 状态
|
||||
if (noConstrainsOnStatusLabel) {
|
||||
BOOL arrowHidden = self.arrowView.isHidden;
|
||||
CGFloat stateCenterX = (self.mj_w + arrowSize.width) * 0.5;
|
||||
self.stateLabel.center = arrowHidden ? selfCenter : CGPointMake(stateCenterX, self.mj_h * 0.5);
|
||||
self.stateLabel.mj_size = CGSizeMake(stateLabelW, self.mj_h) ;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setState:(MJRefreshState)state {
|
||||
MJRefreshCheckState
|
||||
// 根据状态做事情
|
||||
if (state == MJRefreshStateIdle) {
|
||||
if (oldState == MJRefreshStateRefreshing) {
|
||||
[UIView animateWithDuration:self.fastAnimationDuration animations:^{
|
||||
self.arrowView.transform = CGAffineTransformMakeRotation(M_PI);
|
||||
} completion:^(BOOL finished) {
|
||||
self.arrowView.transform = CGAffineTransformIdentity;
|
||||
}];
|
||||
} else {
|
||||
[UIView animateWithDuration:self.fastAnimationDuration animations:^{
|
||||
self.arrowView.transform = CGAffineTransformIdentity;
|
||||
}];
|
||||
}
|
||||
} else if (state == MJRefreshStatePulling) {
|
||||
[UIView animateWithDuration:self.fastAnimationDuration animations:^{
|
||||
self.arrowView.transform = CGAffineTransformMakeRotation(M_PI);
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
28
Pods/MJRefresh/MJRefresh/Custom/Trailer/MJRefreshStateTrailer.h
generated
Normal file
28
Pods/MJRefresh/MJRefresh/Custom/Trailer/MJRefreshStateTrailer.h
generated
Normal file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// MJRefreshStateTrailer.h
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by kinarobin on 2020/5/3.
|
||||
// Copyright © 2020 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_include(<MJRefresh/MJRefreshTrailer.h>)
|
||||
#import <MJRefresh/MJRefreshTrailer.h>
|
||||
#else
|
||||
#import "MJRefreshTrailer.h"
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
||||
@interface MJRefreshStateTrailer : MJRefreshTrailer
|
||||
|
||||
#pragma mark - 状态相关
|
||||
/** 显示刷新状态的label */
|
||||
@property (weak, nonatomic, readonly) UILabel *stateLabel;
|
||||
/** 设置state状态下的文字 */
|
||||
- (instancetype)setTitle:(NSString *)title forState:(MJRefreshState)state;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
87
Pods/MJRefresh/MJRefresh/Custom/Trailer/MJRefreshStateTrailer.m
generated
Normal file
87
Pods/MJRefresh/MJRefresh/Custom/Trailer/MJRefreshStateTrailer.m
generated
Normal file
@@ -0,0 +1,87 @@
|
||||
//
|
||||
// MJRefreshStateTrailer.m
|
||||
// MJRefresh
|
||||
//
|
||||
// Created by kinarobin on 2020/5/3.
|
||||
// Copyright © 2020 小码哥. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MJRefreshStateTrailer.h"
|
||||
#import "NSBundle+MJRefresh.h"
|
||||
#import "UIView+MJExtension.h"
|
||||
|
||||
@interface MJRefreshStateTrailer() {
|
||||
/** 显示刷新状态的label */
|
||||
__unsafe_unretained UILabel *_stateLabel;
|
||||
}
|
||||
/** 所有状态对应的文字 */
|
||||
@property (strong, nonatomic) NSMutableDictionary *stateTitles;
|
||||
@end
|
||||
|
||||
@implementation MJRefreshStateTrailer
|
||||
#pragma mark - 懒加载
|
||||
- (NSMutableDictionary *)stateTitles {
|
||||
if (!_stateTitles) {
|
||||
self.stateTitles = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return _stateTitles;
|
||||
}
|
||||
|
||||
- (UILabel *)stateLabel {
|
||||
if (!_stateLabel) {
|
||||
UILabel *stateLabel = [UILabel mj_label];
|
||||
stateLabel.numberOfLines = 0;
|
||||
[self addSubview:_stateLabel = stateLabel];
|
||||
}
|
||||
return _stateLabel;
|
||||
}
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
- (void)textConfiguration {
|
||||
// 初始化文字
|
||||
[self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshTrailerIdleText] forState:MJRefreshStateIdle];
|
||||
[self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshTrailerPullingText] forState:MJRefreshStatePulling];
|
||||
[self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshTrailerPullingText] forState:MJRefreshStateRefreshing];
|
||||
}
|
||||
|
||||
#pragma mark - 覆盖父类的方法
|
||||
- (void)prepare {
|
||||
[super prepare];
|
||||
|
||||
[self textConfiguration];
|
||||
}
|
||||
|
||||
- (void)i18nDidChange {
|
||||
[self textConfiguration];
|
||||
|
||||
[super i18nDidChange];
|
||||
}
|
||||
|
||||
- (void)setState:(MJRefreshState)state {
|
||||
MJRefreshCheckState
|
||||
// 设置状态文字
|
||||
self.stateLabel.text = self.stateTitles[@(state)];
|
||||
}
|
||||
|
||||
- (void)placeSubviews {
|
||||
[super placeSubviews];
|
||||
|
||||
if (self.stateLabel.hidden) return;
|
||||
|
||||
BOOL noConstrainsOnStatusLabel = self.stateLabel.constraints.count == 0;
|
||||
CGFloat stateLabelW = ceil(self.stateLabel.font.pointSize);
|
||||
// 状态
|
||||
if (noConstrainsOnStatusLabel) {
|
||||
self.stateLabel.center = CGPointMake(self.mj_w * 0.5, self.mj_h * 0.5);
|
||||
self.stateLabel.mj_size = CGSizeMake(stateLabelW, self.mj_h) ;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user