Simple Pull to Refresh Control for iOS. Inspired by WP8.
- Requires iOS 6 or later. The sample project is optimized for iOS 7.
- Requires Automatic Reference Counting (ARC).
See the License. You are free to make changes and use this in either personal or commercial projects. Attribution is not required, but it appreciated. A little Thanks! (or something to that affect) would be much appreciated. If you use BEMSimpleLineGraph in your app, let us know. Please note that Microsoft might not be really happy if you use this control as it looks exactly like what is used on Windows Phone.
Any contribution is more than welcome! You can contribute through pull requests and issues on GitHub.
The iOS Sample App included with this project demonstrates how to correctly setup and use BEMPullToRefreshWP8. You can refer to the sample app for an understanding of how to use and setup BEMPullToRefreshWP8.
To install BEMPullToRefreshWP8 simply drag and drop the PullToRefreshControl folder into your Xcode project. When you do so, check the "Copy items into destination group's folder" box.
To setup BEMPullToRefreshWP8, follow the steps below.
-
Import
"BEMPullToRefresh.h"
to the header of your TableViewController:#import "BEMPullToRefresh.h"
-
Implement the
BEMPullToRefreshDelegate
to the same TableViewController:@interface YourViewController : UITableViewController <BEMPullToRefreshDelegate>
-
Add the following code to your implementation (usually the
viewDidLoad
method).BEMPullToRefresh *myPTR = [[BEMPullToRefresh alloc] initWithNumberOfDots:5]; myPTR.delegate = self; [self.view addSubview:myPTR];
-
Call the method
viewDidScroll:
inscrollViewDidScroll:
to inform the control when the view is scrolled by the user.- (void)scrollViewDidScroll:(UIScrollView *)scrollView { [self.myPTR viewDidScroll:scrollView]; }
-
Implement the requiered method
Refresh
- (void)Refresh { // Perform here the required actions to refresh the data (call a JSON API for example). // Once the data has been updated, call the method isDoneRefreshing: [self.myPTR isDoneRefreshing]; }
The dotColor
property controls the color of the dots.
The thresholdToTrigger
property controls how far the user needs to pull down the tableview for the refresh to be triggered. A value close to 0 will make it really easy to be triggered while a value above 100 will make it really hard.
The animationSpeed
property controls the speed of the dots during the animation. The default value is 1. A value between 0 and 1 will speed up the animation while a value superior to 1 will slow it down.