GithubHelp home page GithubHelp logo

cjd1884 / bezier-refresh-control Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 0.0 218 KB

Refresh control for ios table views

License: MIT License

Swift 66.83% Ruby 0.66% Objective-C 19.66% C 7.62% Shell 5.23%

bezier-refresh-control's Introduction

Bezier Refresh Control

A vector-based (using bezier paths) animated loading control (pull-to-refresh) for iOS scroll views (to be used in table & collection views).

Swift Version CocoaPods Compatible Build Status PRs Welcome License

BezierRefreshControl implements an animated way of drawing bezier paths to be used as a loading control in iOS scroll views - like in case of refreshing the content of a table view (or collection view) - pull-to-refresh action. Developer can provide its own bezier path at the initialisation phase of the control to be animated. The animation executes while data is loading (e.g. fetching data from a remote source/API).

FlameRefreshControl

Features

  • Custom bezier paths support
  • Working in every UIScrollView subclass
  • Color customisation
  • Stroke line width customisation

Requirements

  • iOS 8.0+
  • Xcode 7.3

Installation

CocoaPods

You can use CocoaPods to install BezierRefreshControl by adding it to your Podfile:

platform :ios, '8.0'
use_frameworks!
pod 'BezierRefreshControl'

To get the full benefits import BezierRefreshControl wherever you import UIKit

import UIKit
import BezierRefreshControl

Manually

  1. Download and drop BezierRefreshControl.swift in your project.
  2. Congratulations!

Usage example

Do the import :

import BezierRefreshControl

Create a property in your class:

var refreshControl: BezierRefreshControl!

In your viewDidLoad() method add these:

// Init BezierRefreshControl
self.refreshControl = BezierRefreshControl(inScrollView: self.tableView, withPath: createSampleFlamePath(), bindsScrollViewDelegate: true)

// Set the delegate
self.refreshControl.delegate = self

Notice that you need to provide your UIBezierPath instance as an initialisation argument.

Properties

Color:

self.refreshControl.color = UIColor.red

Stroke line width:

self.refreshControl.lineWidth = 3.0

UIScrollViewDelegate binding

If you noticed at the initialisation phase there is a boolean argument about binding the scroll view delegate. In case you need to implement the scroll view delegate in your code you need to do these two steps:

  1. At the initialisation phase, set bindsScrollViewDelegate argument to false
  2. Inside the implemented (in your code) delegate methods of UIScrollViewDelegate, call the control's publicly exposed methods:
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
self.refreshControl.scrollViewWillBeginDragging(scrollView)
}

func scrollViewDidScroll(_ scrollView: UIScrollView) {
self.refreshControl.scrollViewDidScroll(scrollView)
}

func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
self.refreshControl.scrollViewDidEndDragging(scrollView, willDecelerate: decelerate)
}

Contribute

I would love your contribution to BezierRefreshControl, check the LICENSE file for more info.

About Me

Konstantinos Dimitros | twitter | email | github | linkedin

License

Distributed under the MIT license. See LICENSE for more information.

bezier-refresh-control's People

Contributors

cjd1884 avatar

Stargazers

Stratos Theodorou avatar  avatar  avatar Krishnaprasad Jagadish avatar Leonardo Kaminski Ferreira avatar Bruno Bilescky avatar Kostas Kremizas avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.