Coder Social home page Coder Social logo

augmify / fillableloaders Goto Github PK

View Code? Open in Web Editor NEW

This project forked from polqf/fillableloaders

0.0 1.0 0.0 2.25 MB

Collection of completely customizable progress based loaders based in custom CGPaths written in Swift

Home Page: https://cocoapods.org/pods/FillableLoaders

License: MIT License

Swift 98.43% Ruby 1.57%

fillableloaders's Introduction

PQFFillableLoaders

####Collection of completely customizable progress based loaders drawn using custom CGPaths written in Swift

Waves

Plain

Spike

Rounded

###Demo:

###Changelog:

  • 1.0.0 (7 Aug 2015)
    • Progress based loaders 🎉
    • Added documentation to all the public properties and functions
  • 0.0.2 Initial Release (3 Aug 2015)

###RoadMap:

  • Carthage support

###Quick Start:

- Progress based behaviour

Therea are only 2 necessary things to make the progress based loader work:

  • Create the loader using showProgressBasedLoaderWithPath(path:) or createProgressBasedLoaderWithPath(path:)
  • To update the fill progress, update the progress property of the loader, which goes from 0.0 to 1.0

- Creation

There are four main methods to create the loaders:

showProgressBasedLoaderWithPath(path:), createProgressBasedLoaderWithPath(path:),showLoaderWithPath(path:) and createLoaderWithPath(path:)

showLoaderWithPath(path:) or showProgressBasedLoaderWithPath(path:) are going to call the create one, and after it, are going to call the showLoader() method.

So, it is just a helper method to do everything at once.

If you want to create the loader, and not show it at the same moment, you can use createProgressBasedLoaderWithPath(path:) or createLoaderWithPath(path:) to create it, and when you want to show it, just call showLoader()

Sample code:

		//PROGRESS BASED:
		
		var loader = WavesLoader.createProgressBasedLoaderWithPath(path)
        loader.loaderColor = UIColor.redColor()
        ...
        //Do other stuff
        ...
        loader.showLoader()
		
		//BASIC

        var loader = WavesLoader.createLoaderWithPath(path)
        loader.loaderColor = UIColor.redColor()
        ...
        //Do other stuff
        ...
        loader.showLoader()

- Deletion:

Just call the method removeLoader() and the loader will disappear and will also be removed from its superview.

Sample code:

        loader.removeLoader()

Customization:

Apart from being able to customize the loader shape, you can also customize other properties of the loader. Take a look at the list:

  • progressBased: Bool Indicates if the loader movement is progress based or not (Default: false)
  • progress: CGFloat Loader fill progress from 0.0 to 1.0 . It will automatically fire an animation to update the loader fill progress
  • backgroundColor: UIColor?
    Background of the loader view (transparent by default)
  • loaderColor: UIColor?
    Color of the filled loader
  • loaderBackgroundColor: UIColor?
    Color of the unfilled loader
  • loaderStrokeColor: UIColor?
    Color of the path stroke
  • loaderStrokeWidth: CGFloat
    Width of the path stroke
  • loaderAlpha: CGFloat
    Alpha of the loader view (1.0 by default)
  • cornerRadius: CGFloat
    Corner radius of the loader view (0.0 by default)
  • duration: NSTimeInterval
    Duration of the animations (10.0 by default)
  • rectSize: CGFloat
    Height of the loader view
  • swing: Bool
    Bool to indicate if the loader has to swing when going up (small rotation, not available for the Plain loader)

#####Extra property for Spikes and Rounded loaders:

  • -spikeHeight: CGFloat Height of the spike

###Installation: ####• CocoaPods

use_frameworks!

pod 'FillableLoaders', '~>1.0.0'

####• Carthage

###How to create my own CGPath?

⚠️ The CGPath bounds cannot exceed the bounds of the loaderView:
  • Width: Screen width
  • Height: rectSize property

####• Manually

        let path = CGPathCreateMutable()
        CGPathMoveToPoint(path, nil, 0, height/2)
        CGPathAddLineToPoint(path, nil, width + 100, height/2)
        CGPathAddLineToPoint(path, nil, width + 100, height*2)
        CGPathAddLineToPoint(path, nil, 0, height*2)
        CGPathCloseSubpath(path)
        return path

####• PaintCode

PaintCode is a realy powerful Mac app that can do a lot of things. You can just draw things, and it will automagically create the code for you

In this case we can use it to create BezierPaths, and extract from there the CGPath.

In the case of drawing a star, it is going to give us this code:

//// Star Drawing
var starPath = UIBezierPath()
starPath.moveToPoint(CGPointMake(180, 25))
starPath.addLineToPoint(CGPointMake(195.16, 43.53))
starPath.addLineToPoint(CGPointMake(220.9, 49.88))
starPath.addLineToPoint(CGPointMake(204.54, 67.67))
starPath.addLineToPoint(CGPointMake(205.27, 90.12))
starPath.addLineToPoint(CGPointMake(180, 82.6))
starPath.addLineToPoint(CGPointMake(154.73, 90.12))
starPath.addLineToPoint(CGPointMake(155.46, 67.67))
starPath.addLineToPoint(CGPointMake(139.1, 49.88))
starPath.addLineToPoint(CGPointMake(164.84, 43.53))
starPath.closePath()
UIColor.grayColor().setFill()
starPath.fill()

The only thing we have to do here is extract the CGPath from the UIBezierPath like so:

let myPath = starPath.CGPath
var myLoader = WavesLoader.showProgressBasedLoaderWithPath(myPath)

####• SVG + PaintCode

A feature that I LOVE from PaintCode is that you can import an .svg file, and it is going to create the code to create its BezierPath. Completely awesome.

That's how I did the Github and Twitter logos, for example.

Technical details:

  • Swift 1.2
  • Animations using CAKeyFrameAnimation

###Licenses All source code is licensed under the MIT License.

If you use it, i'll be happy to know about it.

Pol Quintana - @poolqf

fillableloaders's People

Watchers

 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.