ESPullToRefresh
ESPullToRefresh是一個(gè)非常易于開發(fā)者使用的下拉刷新和加載更多組件。通過一個(gè)UIScrollView的擴(kuò)展,可以輕松為UIScrollView的所有子類添加下拉刷新功能。 如果你想定制組件的UI樣式,只要實(shí)現(xiàn)指定的協(xié)議方法即可。Github地址
如何安裝
使用CocoaPods
pod "ESPullToRefresh"
手動(dòng)安裝
git clone https://github.com/eggswift/pull-to-refresh.git
open ESPullToRefresh
開始使用
使用默認(rèn)樣式 效果如下:
設(shè)置默認(rèn)下拉刷新組件
self.tableView.es_addPullToRefresh {
[weak self] in
/// 在這里做刷新相關(guān)事件
/// ...
/// 如果你的刷新事件成功,設(shè)置completion自動(dòng)重置footer的狀態(tài)
self?.tableView.es_stopPullToRefresh(completion: true)
/// 設(shè)置ignoreFooter來處理不需要顯示footer的情況
self?.tableView.es_stopPullToRefresh(completion: true, ignoreFooter: false)
})
}
設(shè)置默認(rèn)加載更多組件
self.tableView.es_addInfiniteScrolling {
[weak self] in
/// 在這里做加載更多相關(guān)事件
/// ...
/// 如果你的加載更多事件成功,調(diào)用es_stopLoadingMore()重置footer狀態(tài)
self?.tableView.es_stopLoadingMore()
/// 通過es_noticeNoMoreData()設(shè)置footer暫無數(shù)據(jù)狀態(tài)
self?.tableView.es_noticeNoMoreData()
})
}
使用自定義樣式 效果如下:
注: 加載動(dòng)畫資源來自美團(tuán) iOS app。
ESPullToRefresh通過ESRefreshProtocol和ESRefreshAnimatorProtocol來約束刷新組件的使用,自定義的組件必須遵守這兩個(gè)協(xié)議,并實(shí)現(xiàn)協(xié)議中的方法。
設(shè)置自定義下拉刷新組件
func es_addPullToRefresh(animator animator: protocol<ESRefreshProtocol, ESRefreshAnimatorProtocol>,
handler: ESRefreshHandler)
設(shè)置自定義加載更多組件
func es_addInfiniteScrolling(animator animator: protocol<ESRefreshProtocol, ESRefreshAnimatorProtocol>,
handler: ESRefreshHandler)
移除方法
func es_removeRefreshHeader()
func es_removeRefreshFooter()
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持html5模板網(wǎng)。
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!