zoukankan      html  css  js  c++  java
  • iOS使用XZMRefresh实现UITableView或UICollectionView横向刷新

    https://blog.csdn.net/u013285730/article/details/50615551?utm_source=blogxgwz6

    XZMRefresh

    The easiest way to use pull-to-The transverse refresh(非常易用的横向刷新框架与MJRefresh用法一致)

    框架开发的缘由:

    现今已有越来越多的APP需要横向刷新的需求,然而MJRefresh已不能满足该需求,这套框架已经使用的非常的广泛,并且框架本身封装比较完美集成使用也非常的简单,方法的使用大家也非常的熟悉,所以XZMRefresh本着模仿MJRefresh框架做了横向刷新的Refresh,这样大家不必再去适应繁琐的新框架集成。

    [github地址]:https://github.com/xiezhongmin/XZMRefresh

    APP实例

    1.好赞APP

    2.淘宝APP

    Content

    使用方法参考 

    默认

    隐藏时间

    动画图片

    [动画图片 + 隐藏状态和时间](#动画图片 + 隐藏状态和时间)

    自定义文字

    特性说明

    如何使用XZMRefresh

    cocoapods导入:pod 'XZMRefresh'

    手动导入:

    将XZMRefresh文件夹中的所有文件拽入项目中

    导入主头文件:#import "XZMRefresh.h"

    下拉刷新控件的种类

    默认(Normal):XZMRefreshNormalHeader

    动图(Gif):XZMRefreshGifHeader

    上拉刷新控件的种类

    默认(Normal):XZMRefreshNormalFooter

    动图(Gif):XZMRefreshGifFooter

    默认

    #pragma mark UICollectionView + 默认刷新

    - (void)addNormalHeader

    {

    __weak typeof(self) weakself = self;

    // 添加下拉刷新头部控件

    [self.collectionView addNormalHeaderWithCallback:^{

    // 增加1条假数据

    weakself.examples += 1;

    // 模拟延迟加载数据,因此2秒后才调用)

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

    [weakself.collectionView reloadData];

    // 结束刷新

    [weakself.collectionView.xzm_header endRefreshing];

    });

    }];

    // 自动刷新(一进入程序就下拉刷新)

    [self.collectionView.xzm_header beginRefreshing];

    }

    隐藏时间

    // 隐藏时间

    self.collectionView.xzm_header.updatedTimeHidden = YES;

    1

    2

    动画图片

    __weak typeof(self) weakself = self;

    // 添加下拉刷新头部控件

    [self.collectionView addGifHeaderWithCallback:^{

    // 进入刷新状态就会回调这个Block

    // 增加1条假数据

    weakself.examples += 1;

    // 模拟延迟加载数据,因此2秒后才调用)

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

    [weakself.collectionView reloadData];

    // 结束刷新

    [weakself.collectionView.xzm_gifHeader endRefreshing];

    });

    }];

    // 设置普通状态的动画图片

    NSMutableArray *idleImages = [NSMutableArray array];

    for (NSUInteger i = 1; i<=60; i++) {

    UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"dropdown_anim__000%zd", i]];

    [idleImages addObject:image];

    }

    [self.collectionView.xzm_gifHeader setImages:idleImages forState:XZMRefreshStateNormal];

    // 设置正在刷新状态的动画图片

    NSMutableArray *refreshingImages = [NSMutableArray array];

    for (NSUInteger i = 1; i<=3; i++) {

    UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"dropdown_loading_0%zd", i]];

    [refreshingImages addObject:image];

    }

    [self.collectionView.xzm_gifHeader setImages:refreshingImages forState:XZMRefreshStateRefreshing];

    // 马上进入刷新状态

    [self.collectionView.xzm_gifHeader beginRefreshing];

    动画图片 + 隐藏状态和时间

    // 添加动画图片代码同上

    // 隐藏时间

    self.collectionView.xzm_gifHeader.updatedTimeHidden = YES;

    // 隐藏状态

    self.collectionView.xzm_gifHeader.stateHidden = YES;

    自定义文字

    // 设置文字

    [self.collectionView.xzm_header setTitle:@"滑动可以刷新" forState:XZMRefreshStateNormal];

    [self.collectionView.xzm_header setTitle:@"释放立即刷新" forState:XZMRefreshStatePulling];

    [self.collectionView.xzm_header setTitle:@"正在刷新中 ..." forState:XZMRefreshStateRefreshing];

    // 设置字体

    self.collectionView.xzm_header.font = [UIFont systemFontOfSize:15];

    // 设置颜色

    self.collectionView.xzm_header.textColor = [UIColor redColor];

    --------------------- 

    作者:配合演出 

    来源:CSDN 

    原文:https://blog.csdn.net/u013285730/article/details/50615551 

    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    Vasya and Endless Credits CodeForces
    Dreamoon and Strings CodeForces
    Online Meeting CodeForces
    数塔取数 基础dp
    1001 数组中和等于K的数对 1090 3个数和为0
    1091 线段的重叠
    51nod 最小周长
    走格子 51nod
    1289 大鱼吃小鱼
    POJ 1979 Red and Black
  • 原文地址:https://www.cnblogs.com/sundaysgarden/p/10490915.html
Copyright © 2011-2022 走看看