A vector-based (using bezier paths) animated loading control (pull-to-refresh) for iOS scroll views (to be used in table & collection views).
BezierRefreshControl implements an animated way of drawing bezier paths to be used as a loading control in iOS scroll views - like in case of refreshing the content of a table view (or collection view) - pull-to-refresh action. Developer can provide its own bezier path at the initialisation phase of the control to be animated. The animation executes while data is loading (e.g. fetching data from a remote source/API).
- Custom bezier paths support
- Working in every UIScrollView subclass
- Color customisation
- Stroke line width customisation
- iOS 8.0+
- Xcode 7.3
You can use CocoaPods to install BezierRefreshControl
by adding it to your Podfile
:
platform :ios, '8.0'
use_frameworks!
pod 'BezierRefreshControl'
To get the full benefits import BezierRefreshControl
wherever you import UIKit
import UIKit
import BezierRefreshControl
- Download and drop
BezierRefreshControl.swift
in your project. - Congratulations!
Do the import :
import BezierRefreshControl
Create a property in your class:
var refreshControl: BezierRefreshControl!
In your viewDidLoad()
method add these:
// Init BezierRefreshControl
self.refreshControl = BezierRefreshControl(inScrollView: self.tableView, withPath: createSampleFlamePath(), bindsScrollViewDelegate: true)
// Set the delegate
self.refreshControl.delegate = self
Notice that you need to provide your
UIBezierPath
instance as an initialisation argument.
Color:
self.refreshControl.color = UIColor.red
Stroke line width:
self.refreshControl.lineWidth = 3.0
If you noticed at the initialisation phase there is a boolean argument about binding the scroll view delegate. In case you need to implement the scroll view delegate in your code you need to do these two steps:
- At the initialisation phase, set
bindsScrollViewDelegate
argument tofalse
- Inside the implemented (in your code) delegate methods of
UIScrollViewDelegate
, call the control's publicly exposed methods:
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
self.refreshControl.scrollViewWillBeginDragging(scrollView)
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
self.refreshControl.scrollViewDidScroll(scrollView)
}
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
self.refreshControl.scrollViewDidEndDragging(scrollView, willDecelerate: decelerate)
}
I would love your contribution to BezierRefreshControl, check the LICENSE
file for more info.
Konstantinos Dimitros | twitter | email | github | linkedin
Distributed under the MIT license. See LICENSE
for more information.