首页 > 代码库 > 继承MJRefresh的自定义刷新控件

继承MJRefresh的自定义刷新控件



#import "SLRefreshHeader.h"
@implementation SLRefreshHeader

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        // 自动切换透明度
        self.automaticallyChangeAlpha = YES;
        // 隐藏时间
        self.lastUpdatedTimeLabel.hidden = YES;
        // 设置文字颜色
        self.stateLabel.textColor = [UIColor redColor];
        [self setTitle:@"赶紧下拉刷新" forState:MJRefreshStateIdle];
        [self setTitle:@"松开??上刷新" forState:MJRefreshStatePulling];
        [self setTitle:@"正在拼命加载数据..." forState:MJRefreshStateRefreshing];
    }
    return self;
}

@end
 

    // header
    self.tableView.mj_header = [SLRefreshHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewTopics)];
    // 让header进入自动刷新
    [self.tableView.mj_header beginRefreshing];

继承MJRefresh的自定义刷新控件