CRRefresh an easy way to use pull-to-refresh, If you want to customize its UI style, you just need conform the specified protocol. We will not regularly updated some nice dynamic effect, at the same time also welcome to write to me ~
中文介绍 / 博客介绍
Screenshots
| | |
---|
NormalAnimator | SlackLoadingAnimator | RamotionAnimator |
| | |
FastAnimator | | |
Requirements
- Xcode 8 or later
- iOS 8.0 or later
- ARC
- Swift 3.0 or later
Features
- Support
UIScrollView
and its subclasses UICollectionView
UITableView
UITextView
- Pull-Down to refresh and Pull-Up to load more
- Support customize your own style(s)
Installation
CocoaPods
CocoaPods is the recommended way to add CRRefresh to your project.
Add a pod entry for CRRefresh to your Podfile.
pod 'CRRefresh'
Second, install CRRefresh into your project:
pod install
Carthage
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate CRRefresh
into your Xcode project using Carthage, specify it in your Cartfile
:
github "CRAnimation/CRRefresh"
Run carthage update
to build the framework and drag the built CRRefresh.framework
(in Carthage/Build/iOS folder) into your Xcode project (Linked Frameworks and Libraries in Targets
).
Manually
- Download the latest code version .
- Open your project in Xcode,drag the
CRRefresh
folder into your project. Make sure to select Copy items when asked if you extracted the code archive outside of your project. - You need it with
import CRRefresh
.
Usage
Add CRRefresh
to your project
import CRRefresh
Add pull-to-refresh
tableView.cr.addHeadRefresh(animator: NormalHeaderAnimator()) { [weak self] in
DispatchQueue.main.asyncAfter(deadline: .now() + 2, execute: {
self?.tableView.cr.endHeaderRefresh()
})
}
tableView.cr.beginHeaderRefresh()
Add infinite-scrolling
tableView.cr.addFootRefresh(animator: NormalFootAnimator()) { [weak self] in
DispatchQueue.main.asyncAfter(deadline: .now() + 2, execute: {
self?.tableView.cr.endLoadingMore()
self?.tableView.cr.noticeNoMoreData()
self?.tableView.cr.resetNoMore()
})
}
Customize Style
Customize refresh need conform the CRRefreshProtocol protocol.
public protocol CRRefreshProtocol {
var view: UIView {get}
var insets: UIEdgeInsets {set get}
var trigger: CGFloat {set get}
var execute: CGFloat {set get}
mutating func refreshBegin(view: CRRefreshComponent)
mutating func refreshEnd(view: CRRefreshComponent, finish: Bool)
mutating func refresh(view: CRRefreshComponent, progressDidChange progress: CGFloat)
mutating func refresh(view: CRRefreshComponent, stateDidChange state: CRRefreshState)
}
Remove
tableView.cr.removeFooter()
tableView.cr.removeHeader()
Contribution
You are welcome to contribute to the project by forking the repo, modifying the code and opening issues or pull requests.
Contacts
If you wish to contact me
License
CRRefresh is released under the MIT license. See LICENSE for details.