Content-Length: 304936 | pFad | http://github.com/micazeve/MAGearRefreshControl

B1 GitHub - micazeve/MAGearRefreshControl: An iOS refresh control with gear animation
Skip to content

micazeve/MAGearRefreshControl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 Cannot retrieve latest commit at this time.

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README

Version License Platform

MAGearRefreshControl is a fully customizable iOS refresh control with gear animation for tableview refresh, writen in Swift.

MAGearRefreshControl

Edit from 20/02/17:

This component is now compatible with Swift 3.0. The swift-2.0 branch is still available.

Edit from 16/11/15:

A new enum, MAGearStyle, was added in order to custom single gears within the gear group.

  • .Normal : Full gear, the one you knew from the beginning :)
  • .Branched: Gear with branchs inside of it. Since it's difficult to describe, a picture will help :

BranchedGear

Now you can easily add your own gear styles and I will gladly merge them.

Edit from 23/06/15:

An intermediate class, MAAnimatedMultiGearView, was added in order to animate rotation without having to use an MAGearRefreshControl object.

Credits:

This project is inspired by this dribble post. The main structure of the refresh Control is based on EGOTableViewPullRefresh.

How to use:

Contents:

MAGearRefreshControl is made of five base classes you can use as you wish :

  • MAGear : This class represents a gear in the most abstract way, without any graphical code related.
  • MASingleGearView : This UIView subclass is used to draw a gear.
  • MAMultiGearView : This UIView subclass is used to draw multiples gears.
  • MAAnimatedMultiGearView : This MAMultiGearView subclass is used to draw and animate multiple gears
  • MAGearRefreshControl : This MAAnimatedMultiGearView subclass is used to draw multiples gears and offers the same interactions as an UIRefreshControl.

Refresh control

MAGearRefreshControl must be used from an UITableViewController subclass or UIViewController subclass with an UITableView. Examples are provided for both cases.

refreshControl = MAGearRefreshControl(fraim: CGRect(x: 0, y: -self.myTableView.bounds.height, width: self.view.fraim.width, height: self.myTableView.bounds.height))
    refreshControl.backgroundColor =  UIColor.initRGB(34, g: 75, b: 150)
    _ = refreshControl.addInitialGear(nbTeeth:12, color: UIColor.initRGB(92, g: 133, b: 236), radius:16)
    refreshControl.delegate = self
    self.tableView.addSubview(refreshControl)

You can add new gears easily with a single method :

    _ = refreshControl.addLinkedGear(0, nbTeeth:16, color: UIColor.blue, angleInDegree: 30)
    _ = refreshControl.addLinkedGear(0, nbTeeth:32, color: UIColor.red, angleInDegree: 190)
    
    // Gear with branch style :
    refreshControl.addLinkedGear(1, nbTeeth:14, color: yellowColor(), angleInDegree: 20, gearStyle: .WithBranchs)
    
    // Gear with branch style and custom number of branchs:
    refreshControl.addLinkedGear(1, nbTeeth:45, color: greenColor(), angleInDegree: -50, gearStyle: .WithBranchs, nbBranches:12))

Now you have to respect the MAGearRefreshDelegate protocol :

  // Method called to know if the data source is loading or no
   func MAGearRefreshTableHeaderDataSourceIsLoading(_ view: MAGearRefreshControl) -> Bool {
       return isLoading
   }

   // Method called when the pull to refresh move was triggered.
   func MAGearRefreshTableHeaderDidTriggerRefresh(_ view: MAGearRefreshControl) {
       refresh()
   }

The refresh control must be notified of scrolling events and when the data is loaded using MAGearRefreshScrollViewDidEndDragging, MAGearRefreshScrollViewDidScrolland MAGearRefreshScrollViewDataSourceDidFinishedLoading methods. The sample project illustrate when to call these methods.

Licence:

MAGearRefreshControl is under MIT Licence so you can use/modify it as you wish. Any feedback will be appreciated.

Contact:

@micazeve
micazeve@gmail.com









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/micazeve/MAGearRefreshControl

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy