An Introduction to Create a Pull Down to Refresh UI View in iOS

In this article, we will introduce how to use ODRefreshControl to create a pull down to refresh ui view in iOS. ODRefreshControl is a “pull down to refresh” control for UIScrollView.

An Introduction to Create a Pull Down to Refresh UI View in iOS

AuthorLinksMade withLast update
Sephiroth87Office HomeObjective-CFeb 14, 2022

How to create?

(1) adding a refresh control to your table view

ODRefreshControl *refreshControl = [[ODRefreshControl alloc] initInScrollView:self.scrollView];

(2) adding event for ODRefreshControl 

[refreshControl addTarget:self action:@selector(dropViewDidBeginRefreshing:) forControlEvents:UIControlEventValueChanged];

There are some customized properties of ODRefreshControl 

They are:

@property (nonatomic, strong) UIColor *tintColor;
@property (nonatomic, assign) UIActivityIndicatorViewStyle activityIndicatorViewStyle;
@property (nonatomic, strong) UIColor *activityIndicatorViewColor; // iOS5 or more