- 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都将变得非常容易。像UITableView
,UICollectionView
,UIWebView
以及WKWebView
。 - These
UIScrollView
categories makes it super easy to add pull-to-refresh and infinite scrolling fonctionalities to anyUIScrollView
(or any of its subclass). LikeUITableView
,UICollectionView
, orUIWebView
andWKWebView
. Adding categories and methods toUIScrollView
makes it easy to add refreshes to all subclasses ofUIScrollView
, yes, that's it!
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)
Download XREasyRefreshControl
project add the files in the Source
directory to your project files.
- Swift 4.0+
- iOS 8.0+
- Xcode 10.0+
- ARC
- Adaptation iPhoneX, iPhone XS, iPhone XS Max, iPhone XR iPhone,iPad,Screen anyway.
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 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 header Refresh
mainCollectionVw.xr.addPullToRefreshHeader(refreshHeader: XRActivityRefreshHeader()) {
// do request...
}
// add footer Refresh
mainCollectionVw.xr.addPullToRefreshFooter(refreshFooter: XRActivityRefreshFooter(), refreshingClosure: {
// do request...
})
// add header Refresh
webView.xr.addPullToRefreshHeader(refreshHeader: XRActivityRefreshHeader()) { [weak self] in
if let weakSelf = self {
weakSelf.webView.reload()
}
}
// add header Refresh
wk_webView.xr.addPullToRefreshHeader(refreshHeader: XRActivityRefreshHeader()) { [weak self] in
if let weakSelf = self {
weakSelf.wk_webView.reload()
}
}
mainTableView.xr.beginHeaderRefreshing()
mainTableView.xr.endHeaderRefreshing()
mainTableView.xr.addPullToLoadingMoreWithRefreshFooter(refreshFooter: XRActivityRefreshFooter(), heightForFooter: 55) {
// do loading more request
}
mainTableView.xr.endFooterRefreshing()
mainTableView.xr.endFooterRefreshingWithNoMoreData()
mainTableView.xr.endFooterRefreshingWithRemoveLoadingMoreView()
mainTableView.xr.endFooterRefreshingWithLoadingFailure()
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.
非常简单,你可以指定 XRRefreshHeader
的ignoreTopHeight
, 以及 XRRefreshFooter
的ignoreBottomHeight
的值,而ignoreBottomHeight
默认已经适配好了,无须设置,当然,你也可以指定你想要的值。适配将变得非常简单。
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.
你可以通过继承 XRBaseRefreshHeader
和 XRBaseRefreshFooter
这两个类,通过写很少的代码就可以自定制出你想要的下拉刷新,上拉加载样式,还可以通过 progressvaluechanged
的值更精确得控制动画。
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.