Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/boztalay/BOZPongRefreshControl
A pull-down-to-refresh control for iOS that plays pong, originally created for the MHacks III iOS app
https://github.com/boztalay/BOZPongRefreshControl
Last synced: 7 days ago
JSON representation
A pull-down-to-refresh control for iOS that plays pong, originally created for the MHacks III iOS app
- Host: GitHub
- URL: https://github.com/boztalay/BOZPongRefreshControl
- Owner: boztalay
- License: mit
- Created: 2013-12-06T18:39:06.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-01-13T18:28:08.000Z (almost 10 years ago)
- Last Synced: 2024-04-29T09:20:55.588Z (8 months ago)
- Language: Objective-C
- Homepage:
- Size: 402 KB
- Stars: 878
- Watchers: 19
- Forks: 68
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - BOZPongRefreshControl - A pull-down-to-refresh control for iOS that plays pong, originally created for the MHacks III iOS app (UI / Pull to Refresh)
- awesome-cocoa - BOZPongRefreshControl
- awesome-ios-star - BOZPongRefreshControl - A pull-down-to-refresh control for iOS that plays pong, originally created for the MHacks III iOS app (UI / Pull to Refresh)
- Awesome-Mobile-UI - BOZPongRefreshControl - C | ![BOZPongRefreshControl](resources/BOZPongRefreshControl.gif) | (ALL)
README
BOZPongRefreshControl
=====================A pull-down-to-refresh control for iOS that plays pong
Installation
------------It's on CocoaPods! Put ```pod 'BOZPongRefreshControl'``` in your Podfile.
Alternatively, just place ```BOZPongRefreshControl.h``` and ```BOZPongRefreshControl.m``` in your project anywhere you'd like.
Usage
--------Attach it to a ```UITableView``` or ```UIScrollView``` like so:
```objective-c
- (void)viewDidLoad
{
[super viewDidLoad];
/* NOTE: Do NOT attach the refresh control in viewDidLoad!
* If you do this here, it'll act very funny if you have
* a navigation bar or other such similar thing that iOS
* automatically offsets content for. You have to wait for
* the subviews to get laid out first so the refresh
* control knows how big that offset is!
*/
}- (void)viewDidLayoutSubviews
{
self.pongRefreshControl = [BOZPongRefreshControl attachToTableView:self.tableView
withRefreshTarget:self
andRefreshAction:@selector(refreshTriggered)];
}
```Then, implement ```UIScrollViewDelegate``` in your ```UIViewController``` if you haven't already, and pass the calls through to the refresh control:
```objective-c
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
[self.pongRefreshControl scrollViewDidScroll];
}- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
[self.pongRefreshControl scrollViewDidEndDragging];
}
```Lastly, make sure you've implemented the ```refreshAction``` you passed it earlier to listen for refresh triggers:
```objective-c
- (void)refreshTriggered
{
//Go and load some data//Finshed loading the data, reset the refresh control
[self.pongRefreshControl finishedLoading];
}
```For more details, check out the demo app's code. It has examples for using the refresh control on a ```UIScrollView``` and outside of a ```UITableViewController```.
Configuration
-------------- Set the foreground color with the ```foregroundColor``` property
- Set the background color with the ```backgroundColor``` property
- Adjust how fast it plays by changing the ```totalHorizontalTravelTimeForBall``` propertyKnown Issues/To Do
------------------- It'll interfere with ```UIScrollView``` content that's above ```y = 0.0f```
- I haven't tested it, but I'd be willing to bet it looks a bit silly on iPads
- Test it out on a physical iPhone 6+
- The behavior of the paddles needs a little work
- The the ```UIScrollView``` that it's attached to is scrolled automatically, the refresh control may be scrolled down into view under some circumstances (expanding/collapsing ```UITableViewCell```s, for example)
- Tests!