Awesome Open Source
Awesome Open Source

XREasyRefreshControl

  • An easy way to use pull-to-refresh
  • 一款强大且支持自定制的iOS平台下,下拉刷新,上拉加载的刷新库。A powerful and lightweight pull-down refresh and pull-up load control.,you can customize your personality refresh according to the requirements.
  • UIScrollView进行扩展,使得向任何有UIScrollView(或其任何子类)添加刷新header和刷新footer都将变得非常容易。像UITableViewUICollectionViewUIWebView以及WKWebView
  • These UIScrollView categories makes it super easy to add pull-to-refresh and infinite scrolling fonctionalities to any UIScrollView (or any of its subclass). Like UITableView, UICollectionView, or UIWebView and WKWebView. Adding categories and methods to UIScrollView makes it easy to add refreshes to all subclasses of UIScrollView, yes, that's it!

How to Use XREasyRefreshControl(如何使用?)

Install From CocoaPods

Add pod 'XREasyRefreshControl' to your Podfile.

  • $ pod install
  • import XREasyRefresh

Swift 5.0, Xcode 10.2.1. is supported in versions 1.2.1 and above. (1.2.1版本以上支持Swift 5.0, Xcode 10.x)

Manual import

Download XREasyRefreshControl project add the files in the Source directory to your project files.

Supports(系统,语言支持)

  • Swift 4.0+
  • iOS 8.0+
  • Xcode 10.0+
  • ARC
  • Adaptation iPhoneX, iPhone XS, iPhone XS Max, iPhone XR iPhone,iPad,Screen anyway.

Usage

Optional (global configuration)(全局配置)

add the code to didFinishLaunchingWithOptions function.

XRRefreshControlSettings.sharedSetting.configSettings(
            animateTimeForAdjustContentInSetTop: 0.5,
            animateTimeForEndRefreshContentInSetTop: 0.3,
            afterDelayTimeForEndInsetTopRefreshing: 0.5,
            pullLoadingMoreMode: .ignorePullReleaseFast,
            refreshStatusLblTextColor: XRRefreshControlSettings.colorFromRGB(hexRGB: 0x333333),
            refreshStatusLblTextFont: UIFont.systemFont(ofSize: 13))
	    

Add refresh to UITableView(为UITableView添加header刷新和footer刷新)

// add header Refresh
mainTableView.xr.addPullToRefreshHeader(refreshHeader: XRActivityRefreshHeader(), heightForHeader: 65, ignoreTopHeight: XRRefreshMarcos.xr_StatusBarHeight) {
	// do request...
}

// add footer Refresh
mainTableView.xr.addPullToRefreshFooter(refreshFooter: XRActivityRefreshFooter(), refreshingClosure: {
	// do request...
})

Add refresh to UICollectionView(为UICollectionView添加header刷新和footer刷新)

// add header Refresh
mainCollectionVw.xr.addPullToRefreshHeader(refreshHeader: XRActivityRefreshHeader()) { 
	// do request...
}

// add footer Refresh
mainCollectionVw.xr.addPullToRefreshFooter(refreshFooter: XRActivityRefreshFooter(), refreshingClosure: {
	// do request...
})

Add refresh to UIWebView(为UIWebView添加header刷新扩展)

// add header Refresh
webView.xr.addPullToRefreshHeader(refreshHeader: XRActivityRefreshHeader()) { [weak self] in
	if let weakSelf = self {
	   weakSelf.webView.reload()
	}
}

Add refresh to WKWebView(为WKWebView添加header刷新扩展)

// add header Refresh
wk_webView.xr.addPullToRefreshHeader(refreshHeader: XRActivityRefreshHeader()) { [weak self] in
	if let weakSelf = self {
	   weakSelf.wk_webView.reload()
	}
}

Auto dropdown refresh(自定进行header下拉刷新)

mainTableView.xr.beginHeaderRefreshing()

End dropdown refresh(结束header刷新)

mainTableView.xr.endHeaderRefreshing()

Add a pull-up load(为UITableView,UICollectionView,UIWebView, WKWebView,UIScrollView添加刷新footer)

mainTableView.xr.addPullToLoadingMoreWithRefreshFooter(refreshFooter: XRActivityRefreshFooter(), heightForFooter: 55) {

	// do loading more request
}

End the pull up load more(结束footer刷新)

mainTableView.xr.endFooterRefreshing()

The end pull-up loads more, showing no more data(结束footer刷新,显示无更多数据提示)

mainTableView.xr.endFooterRefreshingWithNoMoreData()

End the pull up load more, remove the pull up load more controls(结束footer刷新,并移除刷新footer)

mainTableView.xr.endFooterRefreshingWithRemoveLoadingMoreView()

End the pull up load more, load failed, click reload(结束footer的刷新,显示加载失败,点击文字即可重新加载)

mainTableView.xr.endFooterRefreshingWithLoadingFailure()

How to adapt iPhoneX, iPhoneXS, XR, and XS Max? (如何适配iPhoneX, iPhoneXS, XR, and XS Max?)

Very simple, you can specify the value of the ignoreTopHeight of XRRefreshHeader, and the value of ignoreBottomHeight of XRRefreshFooter, and ignoreBottomHeight is already adapted by default, no need to set, of course, you can also specify the value you want. Adaptation will become very simple.

非常简单,你可以指定 XRRefreshHeaderignoreTopHeight, 以及 XRRefreshFooterignoreBottomHeight的值,而ignoreBottomHeight默认已经适配好了,无须设置,当然,你也可以指定你想要的值。适配将变得非常简单。

Reveal(效果图)

image-w200 image-w200 UITableView,UICollectionView UIWebView,WKWebView UIWebView,WKWebView

Customization(如何自定制刷新样式?)

You can inherit the base classes XRBaseRefreshHeader and XRBaseRefreshFooter, override refreshStateChanged, and, if necessary, override progressvaluechanged to customize the drop-down refresh and drop-down loading effects you want.

你可以通过继承 XRBaseRefreshHeaderXRBaseRefreshFooter这两个类,通过写很少的代码就可以自定制出你想要的下拉刷新,上拉加载样式,还可以通过 progressvaluechanged的值更精确得控制动画。

LICENSE

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Swift (64,620
Iphone X (6,379
Iphone (6,379
Footer (2,495
Customize (2,192
Uitableview (1,341
Wkwebview (478
Uiwebview (410
Uicollectionview (267