/EasyPullToRefresh

A single line code to implement pull to refresh and handle empty list message.

Primary LanguageSwiftMIT LicenseMIT

EasyPullToRefresh 📢

CI Status Version License Platform

Easily integrate pull to refresh without any hassle. Handle empty tableview with a single line. No need to add anything to storyboard or xib or code.

Example 📚

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation ⏳

EasyPullToRefresh is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'EasyPullToRefresh'

alt text

Usage 💡

Import the pod inside your viewcontroller class.

import EasyPullToRefresh

After installation the pull to refresh will be available for every tableview inside your project. Use below call back to handle the refresh event.

    self.tableView.customRefresh {
        // You can do your API call here
    }

Similarly if the tableview is empty, a message will be shown along with a reload button. Use below call back to handle reload event.

    self.tableView.customReload {
        // You can do your API call here
    }

If you dont like the colors and theme, override all the controls according to your needs. You can override default colors and appearance for the UIRefreshControl, ReloadButton and DataEmptyLabel. Use Below variable names to access the controls

    // 1: Disable pull to refresh using the flag
    self.tableView.showPullToRefresh = false
    
    // 2: Disable empty tableview message and reload button
    self.tableView.showReloadOnEmpty = false
    
    // 3: Customize the UiRefreshControl
    self.tableView.customRefreshControl.backgroundColor = UIColor.green
    self.tableView.customRefreshControl.tintColor = UIColor.green
    
    // 4: Override custom message for empty tableview using below label
    self.tableView.customEmptyMessageLabel.text = "YOUR CUSTOM TEXT FOR EMPTY LIST"
    
    // 5: Customize the Reload button for empty tableview
    self.tableView.customReloadButton.backgroundColor = UIColor.green
    self.tableView.customReloadButton.layer.borderColor = UIColor.red.cgColor

Author 😇

My email id, harshalrj25@gmail.com

Harshal Jadhav

License

It's all your's 🎁