Skip to content

Commit

Permalink
Updated Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Pol Quintana committed Aug 2, 2015
1 parent af87c2c commit afbd104
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 13 deletions.
Binary file added Images/demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/plain.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/rounded.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/spike.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/waves.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
154 changes: 146 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,166 @@

####Collection of completely customizable loaders based in custom `CGPath`s written in Swift

![jul 26 2015 13 28](https://cloud.githubusercontent.com/assets/7887319/8893760/e4afff0e-339d-11e5-8a26-a483e77e79ac.gif)
<p align="center">
<img src="Images/waves.gif" height="120px"/>
</p>
<p align="center">
Waves
</p>

###RoadMap
<p align="center">
<img src="Images/plain.gif" height="120px"/>
</p>
<p align="center">
Plain
</p>

- Progress based Loader
- Pods support
- Carthage support
<p align="center">
<img src="Images/spike.gif" height="120px"/>
</p>
<p align="center">
Spike
</p>

<p align="center">
<img src="Images/rounded.gif" height="120px"/>
</p>
<p align="center">
Rounded
</p>

###Installation

###Demo:
<p align="center">
<img src="Images/demo.png" height="300px"/>
</p>

###RoadMap:

- [ ] CocoaPods support
- [ ] Carthage support
- [ ] Progress based animations

###Quick Start:
#### - Creation
There are two main methods to create the loaders:

`showLoaderWithPath:` and `createLoaderWithPath:`

`showLoaderWithPath:` is going to call the create one, and after it, is 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 `createLoaderWithPath:` to create it, and when you want to show it, just call `showLoader`

Sample code:

```
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:

- __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 view 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
####• Carthage

###Quick Start

###How to create my own CGPath?

####• 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](http://www.paintcodeapp.com)__ 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.showLoaderWithPath(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.

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

Expand Down
4 changes: 1 addition & 3 deletions Source/FillableLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ class FillableLoader: UIView {

// MARK: Public Variables

var duration: NSTimeInterval = 1.0
var fontSize: CGFloat = 14.0
var duration: NSTimeInterval = 10.0
var rectSize: CGFloat = UIScreen.mainScreen().bounds.height/6 + 30
var swing: Bool = true

Expand Down Expand Up @@ -182,7 +181,6 @@ class FillableLoader: UIView {

internal func defaultValues() {
duration = 10.0
fontSize = 14.0
backgroundColor = UIColor.clearColor()
loaderColor = UIColor(red: 0.41, green: 0.728, blue: 0.892, alpha: 1.0)
loaderBackgroundColor = UIColor.whiteColor()
Expand Down
4 changes: 2 additions & 2 deletions Source/PlainLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ class PlainLoader: FillableLoader {
var variation: CGFloat = 10

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

0 comments on commit afbd104

Please sign in to comment.