Skip to content
Yet another and better refresh control for scroll views.
Objective-C Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Classes
PRRefreshControlDemo.xcodeproj
PRRefreshControlDemo
PRRefreshControlDemoTests
Resources/PRRefreshControl.bundle
.gitignore
LICENSE
PRRefreshControl.podspec
README.md

README.md

PRRefreshControl

CocoaPods Language License

Tweet Twitter

Yet another and better refresh control for scroll views.

Installation

With CocoaPods

In your Podfile:

pod 'PRRefreshControl'

Usage

Setup in -viewDidLoad in your view controller class:

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    ...
    
    PRRefreshControl *refreshControl = [[PRRefreshControl alloc] init];
    [refreshControl addTarget:self
                       action:@selector(refreshControlTriggered:)
             forControlEvents:UIControlEventValueChanged];
    self.refreshControl = refreshControl;
    [collectionView insertSubview:refreshControl atIndex:0];
    
    // Configure manually if needed
    CGFloat customMarginTop = 10.f;
    refreshControl.scrollViewContentInset = collectionView.contentInset;
    refreshControl.height -= customMarginTop;
    refreshControl.verticalOffset = customMarginTop * .5f;
    
    ...
    
}

Respond to actions:

#pragma mark - Data

- (void)dataDidRefresh
{
    [self.refreshControl endRefreshing];
}

#pragma mark - Actions

- (void)refreshControlTriggered:(PRRefreshControl *)sender
{
    [self refreshData];
}

All done!

License

This code is distributed under the terms and conditions of the MIT license.

Donate

You can support me by:

:-)

Contact

You can’t perform that action at this time.