TGRefreshOC 0.1.3

TGRefreshOC 0.1.3

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后更新2017年6月

targetcloud 维护。



  • 作者
  • targetcloud

弹簧、橡皮筋下拉刷新控件,类似 QQ 下拉刷新控件,但功能更强大,同时支持其他样式,目前共 2 种样式,后续将不断增加...

最近更新

  • 0.1.3 版增加 ignoreScrollViewContentInsetTop 属性
  • 0.1.2 版增加回显信息的渐显与渐隐时间属性设置
  • 0.1.1 版优化并增强容错设计处理
  • 0.1.0 版去掉了计时器,提高了性能,同时增加了容错性设计处理

功能

  • [x] 支持链式编程配置,程序员的最爱
  • [x] 支持两种刷新结果提示
  • [x] 支持QQ和Normal两种下拉刷新样式
  • [x] 支持contentInset
  • [x] 支持Cocoapods
  • [x] 支持MJRefresh到TGRefresh风格切换,只需将 mj_header 替换为 tg_header,只需改动两个字母即可
  • [x] 支持4种配置方式,普通配置、一句式配置、高级配置、最优配置,推荐使用最优配置
  • [x] 支持刷新结果回显配置
  • [x] 超轻量级、使用超灵活、功能超强大
  • [x] 用例丰富,快速上手

使用方法

首先写下这一句(必须的)

#import <TGRefresh.h>

如果需要,在你的控制器中添加以下语句

self.automaticallyAdjustsScrollViewInsets=NO;

QQ 效果

self.tableview.tg_header = [TGRefreshOC  refreshWithTarget:self action:@selector(doRefreshSenior) config:nil];

普通效果

    self.tableview.tg_header = [TGRefreshOC  refreshWithTarget:self action:@selector(doRefreshSenior) config:^(TGRefreshOC *refresh) {
        refresh.tg_kind(RefreshKindNormal);
    }];

更多配置,使用链式编程配置

    self.tableview.tg_header = [TGRefreshOC  refreshWithTarget:self action:@selector(doRefreshSenior) config:^(TGRefreshOC *refresh) {
        refresh.tg_refreshResultBgColor([[UIColor orangeColor] colorWithAlphaComponent:0.8])
        .tg_bgColor([UIColor colorWithWhite:0.8 alpha:1])
        .tg_refreshResultTextColor([UIColor whiteColor]);
    }];

开始刷新

[self.tableview.tg_header beginRefreshing];

(在如网络请求等情况得到数据后)结束刷新

[self.tableview.tg_header endRefreshing];

结束刷新时的回显

        self.tableview.tg_header.refreshResultStr = @"成功刷新数据来自回显信息”;
        [self.tableview.tg_header endRefreshing];

可配置的属性

/** 类型,默认为QQ弹簧 皮筋效果 */
@property(nonatomic,assign) TGRefreshKind kind;
/** 背景色(在有contentInset时为scrollview等背景色) */
@property(nonatomic,strong) UIColor * bgColor;
/** 主题色(刷新文字颜色、ActivityIndicator颜色、橡皮筯颜色) */
@property(nonatomic,strong) UIColor * tinColor;
/** 垂直对齐,默认顶部 */
@property(nonatomic,assign) TGRefreshAlignment verticalAlignment;
/** 刷新成功时的提示文字 */
@property(nonatomic,copy) NSString * refreshSuccessStr;
/** 准备刷新时的提示文字 */
@property(nonatomic,copy) NSString * refreshNormalStr;
/** 即将刷新时的提示文字 */
@property(nonatomic,copy) NSString * refreshPullingStr;
/** 正在刷新时的提示文字 */
@property(nonatomic,copy) NSString * refreshingStr;
/** 更新结果的回显文字 */
@property(nonatomic,copy) NSString * refreshResultStr;
/** 更新结果的回显背景色 */
@property(nonatomic,strong) UIColor * refreshResultBgColor;
/** 更新结果的回显文字颜色 */
@property(nonatomic,strong) UIColor * refreshResultTextColor;
/** 更新结果的回显高度 */
@property(nonatomic,assign) CGFloat refreshResultHeight;
/** 自动改变透明度,默认已做优化 */
@property(nonatomic,assign) BOOL automaticallyChangeAlpha;
/** 回显时的渐显时间 0.1 ~ 2秒 默认0.5 */
@property(nonatomic,assign) CGFloat fadeinTime;
/** 回显时的渐隐时间 0.1 ~ 5秒 默认1.5 */
@property(nonatomic,assign) CGFloat fadeoutTime;
/** 忽略初始的InsetTop */
@property(nonatomic,assign) BOOL ignoreScrollViewContentInsetTop;

使用链式编程配置时,请在所有属性前加 tg_ 前缀即可

更多使用配置组合效果,请下载本项目或 Fork 本项目查看

安装

  • 下载并将 TGRefreshOC 拖动到您的工程中,只需拖动包含 TGRefresh.h 文件的目录即可

  • Cocoapods

pod 'TGRefreshOC'

参考

运行效果

demo 中的弹簧效果

demo中的Normal效果

如果你觉得好,请Star