使用的时候调用下面的代码:
self.tableView.mj_header = [MJRefreshManager defaultHeader:^{
}];
MJRefreshManager文件
#import <Foundation/Foundation.h>
#import <MJRefresh/MJRefresh.h>
@interface MJRefreshManager : NSObject
+ (MJRefreshNormalHeader *)defaultHeader:(MJRefreshComponentRefreshingBlock)refreshingBlock;
+ (MJRefreshAutoNormalFooter *)defaultFooter:(MJRefreshComponentRefreshingBlock)refreshingBlock;
+ (MJRefreshAutoNormalFooter *)loadingDataNoTextFooter:(MJRefreshComponentRefreshingBlock)refreshingBlock;
@end
#import "MJRefreshManager.h"
@implementation MJRefreshManager
+ (MJRefreshNormalHeader *)defaultHeader:(MJRefreshComponentRefreshingBlock)refreshingBlock {
// __weak typeof(self) weakSelf = self;
MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingBlock:refreshingBlock];
[header setTitle:@"正在加载" forState:MJRefreshStateRefreshing];
// 往下拉的时候文字
[header setTitle:@"下拉刷新" forState:MJRefreshStateIdle];
// 松手时候的文字
[header setTitle:@"松开刷新" forState:MJRefreshStatePulling];
// 隐藏时间
header.lastUpdatedTimeLabel.hidden = YES;
// 设置字体
header.stateLabel.font = [UIFont fontWithName:Font_PingFang_Regular size:14];
header.lastUpdatedTimeLabel.font = [UIFont fontWithName:Font_PingFang_Regular size:14];
return header;
}
+ (MJRefreshAutoNormalFooter *)defaultFooter:(MJRefreshComponentRefreshingBlock)refreshingBlock {
MJRefreshAutoNormalFooter *footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:refreshingBlock];
[footer setTitle:@"上拉或点击加载更多" forState:MJRefreshStateIdle];
[footer setTitle:@"正在加载" forState:MJRefreshStateRefreshing];
[footer setTitle:@"已加载全部" forState:MJRefreshStateNoMoreData];
footer.stateLabel.font = [UIFont fontWithName:Font_PingFang_Regular size:14];
return footer;
}
+ (MJRefreshAutoNormalFooter *)loadingDataNoTextFooter:(MJRefreshComponentRefreshingBlock)refreshingBlock {
MJRefreshAutoNormalFooter *footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:refreshingBlock];
[footer setTitle:@"加载失败,点击重新加载" forState:MJRefreshStateIdle];
[footer setTitle:@"正在加载" forState:MJRefreshStateRefreshing];
[footer setTitle:@"" forState:MJRefreshStateNoMoreData];
footer.stateLabel.font = [UIFont fontWithName:Font_PingFang_Regular size:14];
return footer;
}
@end