{"id":21373992,"url":"https://github.com/Yalantis/PullToRefresh","last_synced_at":"2025-07-13T08:31:52.046Z","repository":{"id":44729532,"uuid":"36059370","full_name":"Yalantis/PullToRefresh","owner":"Yalantis","description":"This component implements pure pull-to-refresh logic and you can use it for developing your own pull-to-refresh animations","archived":false,"fork":false,"pushed_at":"2020-11-09T09:45:35.000Z","size":200,"stargazers_count":1264,"open_issues_count":12,"forks_count":203,"subscribers_count":45,"default_branch":"master","last_synced_at":"2025-06-24T01:02:08.027Z","etag":null,"topics":["animation","cocoapods","ios","pull-to-refresh","refresh-animations","refreshview","swift","tableview","yalantis"],"latest_commit_sha":null,"homepage":"https://yalantis.com","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Yalantis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-22T07:51:25.000Z","updated_at":"2025-06-18T10:07:17.000Z","dependencies_parsed_at":"2022-09-13T15:20:22.548Z","dependency_job_id":null,"html_url":"https://github.com/Yalantis/PullToRefresh","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/Yalantis/PullToRefresh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yalantis%2FPullToRefresh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yalantis%2FPullToRefresh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yalantis%2FPullToRefresh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yalantis%2FPullToRefresh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yalantis","download_url":"https://codeload.github.com/Yalantis/PullToRefresh/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yalantis%2FPullToRefresh/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265109750,"owners_count":23712745,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["animation","cocoapods","ios","pull-to-refresh","refresh-animations","refreshview","swift","tableview","yalantis"],"created_at":"2024-11-22T08:29:37.780Z","updated_at":"2025-07-13T08:31:51.730Z","avatar_url":"https://github.com/Yalantis.png","language":"Swift","readme":"# Customizable PullToRefresh\n\nThis component implements pure pull-to-refresh logic and you can use it for developing your own pull-to-refresh animations, [like this one.](https://github.com/Yalantis/PullToMakeSoup)\n\n[![Yalantis](https://raw.githubusercontent.com/Yalantis/PullToRefresh/develop/PullToRefreshDemo/Resources/badge_dark.png)](https://yalantis.com/?utm_source=github)\n\n## Requirements\n\n- iOS 8.0+\n- Swift 5.0 (v 3.2+)\n- Swift 4.2 (v 3.1+)\n- Swift 3 (v. 2.0+)\n- Swift 2 (v. 1.4)\n\n## Installing\n\n### with [CocoaPods](https://cocoapods.org)\n```ruby\nuse_frameworks!\npod 'PullToRefresher'\n```\n### with [Carthage](https://github.com/Carthage/Carthage)\n```ruby\ngithub \"Yalantis/PullToRefresh\"\n```\n\n## Usage\n\nAt first, import PullToRefresh:\n\n```swift\nimport PullToRefresh\n```\n\nThe easiest way to create *PullToRefresh*:\n\n```swift\nlet refresher = PullToRefresh()\n```\n\nIt will create a default pull-to-refresh with a simple view which has single *UIActivitiIndicatorView*. To add refresher to your *UIScrollView* subclass:\n\n```swift\ntableView.addPullToRefresh(refresher) {\n    // action to be performed (pull data from some source)\n}\n```\n\n⚠️ Don't forget to remove pull to refresh when your view controller is releasing. ⚠️\n\n```swift\ndeinit {\n    tableView.removeAllPullToRefresh()\n}\n```\n\nAfter the action is completed and you want to hide the refresher:\n\n```swift\ntableView.endRefreshing()\n```\n\nYou can also start refreshing programmatically:\n\n```swift\ntableView.startRefreshing()\n```\n\nBut you probably won’t use this component, though. *UITableViewController* and *UICollectionViewController* already have a simple type of refresher.\nIt’s much more interesting to develop your own pull-to-refresh control.\n\n## Usage in UITableView with sections\n\nUnfortunaly, *UITableView* with sections currently not supported. But you can resolve this problem in two steps:\n1) Create you own *PullToRefresh* (see instructions below).\n2) Set its ```shouldBeVisibleWhileScrolling``` property to ```true```. It makes you PullToRefresh always visible while you're scrolling the table. \n\n⚠️ By default PullToRefresh has transparent background which leads to unwanted overlapping behavour. ⚠️\n\n## Disable/Enable\n\nYou can disable/enable refresher in runtime:\n\n```Swift\nyourRefresher.setEnable(isEnabled: false)\n```\n\n## Creating custom PullToRefresh\n\nTo create a custom refresher you would need to initialize *PullToRefresh* class with two objects:\n\n- **refreshView** is a UIView object which will added to your scroll view;\n- **animator** is an object which will animate elements on refreshView depending on the state of PullToRefresh.\n\n```swift\nlet awesomeRefresher = PullToRefresh(refresherView: yourView, animator: yourAnimator)\n```\n\n### Steps for creating custom PullToRefresh\n\n1) Create a custom *UIView* with *.xib and add all images that you want to animate as subviews. Pin them with outlets:\n\n```swift\nclass RefreshView: UIView {\n\n    @IBOutlet private var imageView: UIImageView!\n  \n    // and others\n}\n```\n\n2) Create an *Animator* object that conforms *RefreshViewAnimator* protocol and can be initialized by your custom view:\n\n```swift\nclass Animator: RefreshViewAnimator {\n\n    private let refreshView: RefreshView\n    \n    init(refreshView: RefreshView) {\n        self.refreshView = refreshView\n    }\n\n    func animate(state: State) {\n        // animate refreshView according to state\n    }\n}\n```\n\n3) According to RefreshViewAnimator protocol, your animator should implement *animateState* method. This method is get called by *PullToRefresh* object every time its state is changed. There are four states:\n\n```swift\npublic enum State: Equatable, CustomStringConvertible {\n    \n    case initial\n    case releasing(progress: CGFloat)\n    case loading\n    case finished\n}\n```\n\n- **Initial** - refresher is ready to be pulled.\n- **Releasing** - refresher is in the process of releasing (by a user or programmatically). This state contains a double value which represents releasing progress from 0 to 1.\n- **Loading** - refresher is in the loading state.\n- **Finished** - loading is finished.\n\nDepending on the state that your animator gets from the *PullToRefresh*, it has to animate elements in *refreshView*:\n\n```swift\nfunc animate(state: State) {\n    switch state {\n      case .initial: // do inital layout for elements\n      case .releasing(let progress): // animate elements according to progress\n      case .loading: // start loading animations\n      case .finished: // show some finished state if needed\n    }\n}\n```\n\nPlace the magic of animations insted of commented lines.\n\n4) For the convitience sake you can sublass from *PullToRefresh* and create separate class for your refresher:\n\n```swift\nclass AwesomePullToRefresh: PullToRefresh {\n\n    convenience init() {\n        let refreshView = Bundle(for: type(of: self)).loadNibNamed(\"RefreshView\", owner: nil, options: nil)!.first as! RefreshView\n        let animator = Animator(refreshView: refreshView)\n        self.init(refreshView: refreshView, animator: animator)\n    }\n}\n```\n\n5) Finally, add a refresher to a UIScrollView subclass:\n\n```swift\ntableView.addPullToRefresh(refresher) {\n    // action to be performed (pull data from some source)\n}\n```\n\nHave fun! :)\n\n## Let us know!\n\nWe’d be really happy if you sent us links to your projects where you use our component. Just send an email to github@yalantis.com And do let us know if you have any questions or suggestion regarding the animation. \n\nP.S. We’re going to publish more awesomeness wrapped in code and a tutorial on how to make UI for iOS (Android) better than better. Stay tuned!\n\n\n## License\n\n\tThe MIT License (MIT)\n\n\tCopyright © 2018 Yalantis\n\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\n\n","funding_links":[],"categories":["OOM-Leaks-Crash"],"sub_categories":["Refresh"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FYalantis%2FPullToRefresh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FYalantis%2FPullToRefresh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FYalantis%2FPullToRefresh/lists"}