使用CocoaPods加载三方库:

pod 'MJRefresh'

MJRefresh类结构图:

具体实现方法和效果图:

  • The drop-down refresh 01-Default

    self.tableView.header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
    //Call this Block When enter the refresh status automatically
    }];

    // Set the callback(Once you enter the refresh status,then call the action of target,that is call [self loadNewData])
    self.tableView.header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)]; // Enter the refresh status immediately
    [self.tableView.header beginRefreshing];

  • The drop-down refresh 02-Animation image

    // Set the callback(一Once you enter the refresh status,then call the action of target,that is call [self loadNewData])
    MJRefreshGifHeader *header = [MJRefreshGifHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)];
    // Set the ordinary state of animated images
    [header setImages:idleImages forState:MJRefreshStateIdle];
    // Set the pulling state of animated images(Enter the status of refreshing as soon as loosen)
    [header setImages:pullingImages forState:MJRefreshStatePulling];
    // Set the refreshing state of animated images
    [header setImages:refreshingImages forState:MJRefreshStateRefreshing];
    // Set header
    self.tableView.mj_header = header;

  • The drop-down refresh 03-Hide the time

    // Hide the time
    header.lastUpdatedTimeLabel.hidden = YES;

  • The drop-down refresh 04-Hide status and time

    // Hide the time
    header.lastUpdatedTimeLabel.hidden = YES; // Hide the status
    header.stateLabel.hidden = YES;

  • The drop-down refresh 05-DIY title

    // Set title
    [header setTitle:@"Pull down to refresh" forState:MJRefreshStateIdle];
    [header setTitle:@"Release to refresh" forState:MJRefreshStatePulling];
    [header setTitle:@"Loading ..." forState:MJRefreshStateRefreshing]; // Set font
    header.stateLabel.font = [UIFont systemFontOfSize:];
    header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:]; // Set textColor
    header.stateLabel.textColor = [UIColor redColor];
    header.lastUpdatedTimeLabel.textColor = [UIColor blueColor];

  • The drop-down refresh 06-DIY the control of refresh

    self.tableView.mj_header = [MJDIYHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)];
    // Implementation reference to MJDIYHeader.h和MJDIYHeader.m

  • The pull to refresh 01-Default

    self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
    //Call this Block When enter the refresh status automatically
    }];

    // Set the callback(Once you enter the refresh status,then call the action of target,that is call [self loadMoreData])
    self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];

  • The pull to refresh 02-Animation image

    // Set the callback(Once you enter the refresh status,then call the action of target,that is call [self loadMoreData])
    MJRefreshAutoGifFooter *footer = [MJRefreshAutoGifFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)]; // Set the refresh image
    [footer setImages:refreshingImages forState:MJRefreshStateRefreshing]; // Set footer
    self.tableView.mj_footer = footer;

  • The pull to refresh 03-Hide the title of refresh status

    // Hide the title of refresh status
    footer.refreshingTitleHidden = YES;
    // If does have not above method,then use footer.stateLabel.hidden = YES;

  • The pull to refresh 04-All loaded

    //Become the status of NoMoreData
    [footer noticeNoMoreData];

  • The pull to refresh 05-DIY title

    // Set title
    [footer setTitle:@"Click or drag up to refresh" forState:MJRefreshStateIdle];
    [footer setTitle:@"Loading more ..." forState:MJRefreshStateRefreshing];
    [footer setTitle:@"No more data" forState:MJRefreshStateNoMoreData]; // Set font
    footer.stateLabel.font = [UIFont systemFontOfSize:]; // Set textColor
    footer.stateLabel.textColor = [UIColor blueColor];

  • The pull to refresh 06-Hidden After loaded

    //Hidden current control of the pull to refresh
    self.tableView.mj_footer.hidden = YES;

  • The pull to refresh 07-Automatic back of the pull01

    self.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];

  • The pull to refresh 08-Automatic back of the pull02

    MJRefreshBackGifFooter *footer = [MJRefreshBackGifFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
    
    // Set the normal state of the animated image
    [footer setImages:idleImages forState:MJRefreshStateIdle];
    // Set the pulling state of animated images(Enter the status of refreshing as soon as loosen)
    [footer setImages:pullingImages forState:MJRefreshStatePulling];
    // Set the refreshing state of animated images
    [footer setImages:refreshingImages forState:MJRefreshStateRefreshing]; // Set footer
    self.tableView.mj_footer = footer;

  • The pull to refresh 09-DIY the control of refresh(Automatic refresh)

    self.tableView.mj_footer = [MJDIYAutoFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
    // Implementation reference to MJDIYAutoFooter.h和MJDIYAutoFooter.m

  • The pull to refresh 10-DIY the control of refresh(Automatic back)

    self.tableView.mj_footer = [MJDIYBackFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
    // Implementation reference to MJDIYBackFooter.h和MJDIYBackFooter.m

  • UICollectionView01-The pull and drop-down refresh

    // The drop-down refresh
    self.collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
    //Call this Block When enter the refresh status automatically
    }]; // The pull to refresh
    self.collectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
    //Call this Block When enter the refresh status automatically
    }];

  • UIWebView01-The drop-down refresh

    //Add the control of The drop-down refresh
    self.webView.scrollView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
    //Call this Block When enter the refresh status automatically
    }];

文章来源:https://github.com/CoderMJLee/MJRefresh

最新文章

  1. Linux:使用nohup让进程在后台可靠运行
  2. Java RSA 分段加解密
  3. PHP 上传大文件
  4. java抽象类和接口区别
  5. Java学习笔记——static关键字与静态的使用方法
  6. javamail模拟邮箱功能发送电子邮件-基础实战篇(javamail API电子邮件实例)
  7. 《第一行代码》学习笔记36-服务Service(3)
  8. 在MAC系统里添加开机启动任务(但是怎么才能知道自己程序的固定位置呢?)
  9. 解决mysql不是内部或外部命令
  10. jQuery的deferred对象实战应用(附:Exchar动态多条数据展示并在topic展示详细数据)
  11. 剑指Offer-翻转单词顺序列
  12. 基本 SQL 之增删改查(二)
  13. klearn.preprocessing.PolynomialFeatures学习
  14. 上传文件报错--Unable to find 'struts.multipart.saveDir' property setting.
  15. MD5加密算法Java代码实现
  16. oracle之 ORA-12557: TNS: 协议适配器不可加载
  17. java深拷贝与浅拷贝
  18. 学习Memcached:2基本应用之控制台使用
  19. Oracle学习笔记:with as子查询用法
  20. Vue路由获取路由参数

热门文章

  1. Git删除master branch中最近一次的提交
  2. 2016 年排名 Top 100 的 Java 类库
  3. CodeForces 124C【连通块】
  4. Hyperledger Cello 安装遇到问题
  5. 洛谷P3193 [HNOI2008]GT考试(KMP,矩阵)
  6. 解决LINUX下SQLPLUS时上下左右键乱码问题
  7. JNI/NDK开发
  8. 【补档】Pycharm的一些配置
  9. PHP 获取acm近期比赛
  10. APP请求超时问题-ios超时-android超时