下拉刷新LNRefresh简介

GitHub :https://github.com/wedxz/LNRefresh

LNRefresh

LNRefresh Is a lightweight, can dynamically expand the drop-down refresh component

Support what kinds of controls to refresh

UIScrollViewUITableViewUICollectionViewUIWebViewUITextView

Demo

GIF picture from 华尔街见闻

Usually style

Dynamically change the style

Installation

CocoaPods

Installation with CocoaPods:

pod 'LNRefresh'

Carthage

Installation with Cartfile:

github "wedxz/LNRefresh"

Documents

How to use LNRefresh

Add pull to refresh
__weak typeof (self) wself = self;
//UITableView
[self.tableView addPullToRefresh:^{
  [wself pullToRefresh];
}];

//UICollectionView
[self.collectionView addPullToRefresh:^{
  [wself pullToRefresh];
}];

//UIWebView
[self.webView.scrollView addPullToRefresh:^{
   [wself.webView reload];
}];
End Pull to refresh
//UITableView
[self.tableView endRefreshing];

//UICollectionView
[self.collectionView endRefreshing];

//UIWebView
[self.webView.scrollView endRefreshing];
Add Loading more
//UITableView
[self.tableView addInfiniteScrolling:^{
  [wself loadMoreRefresh];
}];

//UICollectionView
[self.collectionView addInfiniteScrolling:^{
  [wself loadMoreRefresh];
}];
End Loading more
//UITableView
[self.tableView endLoadingMore];

//UICollectionView
[self.tableView endLoadingMore];
No More data
//UITableView
[self.tableView noticeNoMoreData];

//UICollectionView
[self.tableView noticeNoMoreData];
Auto Refresh
[self.scrollView startRefreshing];
Change the trigger to pull the refresh distance
self.tableView.ln_header.animator.trigger = 100;

Global Settings

Set the GIF image
+ (void)setAllHeaderAnimatorStateImages:(NSArray *)stateImages
                                  state:(LNRefreshState)state;

+ (void)setAllHeaderAnimatorStateImages:(NSArray *)stateImages
                                  state:(LNRefreshState)state
                               duration:(NSTimeInterval)duration;
Change the global pull-down refresh pattern state
+ (void)changeAllHeaderAnimatorType:(LNRefreshHeaderType)type;

+ (void)changeAllHeaderAnimatorType:(LNRefreshHeaderType)type
                            bgImage:(UIImage *)image;

+ (void)changeAllHeaderAnimatorType:(LNRefreshHeaderType)type
                            bgImage:(UIImage *)image
                        incremental:(CGFloat)incremental;

Customize RefreshAnimator

You Need to inherit LNHeaderAnimator,Rewrite the following method.

- (void)setupHeaderView_DIY;
- (void)layoutHeaderView_DIY;
- (void)refreshHeaderView_DIY:(LNRefreshState)state;
- (void)endRefreshAnimation_DIY:(LNRefreshComponent *)view;
- (void)startRefreshAnimation_DIY:(LNRefreshComponent *)view;
- (void)refreshView_DIY:(LNRefreshComponent *)view progress:(CGFloat)progress;

Example: LNHeaderDIYAnimator.m

Analysis

Example: LNHeaderAnimator+Analysis.m

Contribution

vvusu

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容