Skip to content

Commit

Permalink
Update Demo and README
Browse files Browse the repository at this point in the history
  • Loading branch information
yoavlt committed Aug 24, 2015
1 parent f4c94ed commit 28fbec4
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 14 deletions.
25 changes: 25 additions & 0 deletions Example/LiquidLoader/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,37 @@
//

import UIKit
import LiquidLoader

class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.

self.view.backgroundColor = UIColor(red: 9 / 255.0, green: 21 / 255.0, blue: 37 / 255.0, alpha: 1.0)

let lineColor = UIColor(red: 77 / 255.0, green: 255 / 255.0, blue: 182 / 255.0, alpha: 1.0)

let lineFrame = CGRect(x: self.view.frame.width * 0.5 - 100, y: 100, width: 200, height: 100)
let lineLoader = LiquidLoader(frame: lineFrame, effect: .GrowLine(lineColor))

let circleFrame = CGRect(x: self.view.frame.width * 0.5 - 100, y: 200, width: 200, height: 200)
let circleColor = UIColor(red: 77 / 255.0, green: 182 / 255.0, blue: 255 / 255.0, alpha: 1.0)
let circleLoader = LiquidLoader(frame: circleFrame, effect: .GrowCircle(circleColor))

let circleMatColor = UIColor(red: 255 / 255.0, green: 188 / 255.0, blue: 188 / 255.0, alpha: 1.0)
let circleMatFrame = CGRect(x: self.view.frame.width * 0.5 - 25, y: 450, width: 50, height: 50)
let circleMat = LiquidLoader(frame: circleMatFrame, effect: .Circle(circleMatColor))

let lineMatColor = UIColor(red: 255 / 255.0, green: 255 / 255.0, blue: 188 / 255.0, alpha: 1.0)
let lineMatFrame = CGRect(x: self.view.frame.width * 0.5 - 25, y: 500, width: 50, height: 50)
let lineMat = LiquidLoader(frame: lineMatFrame, effect: .Line(lineMatColor))

view.addSubview(lineLoader)
view.addSubview(circleLoader)
view.addSubview(circleMat)
view.addSubview(lineMat)
}

override func didReceiveMemoryWarning() {
Expand Down
8 changes: 4 additions & 4 deletions Pod/Classes/LiquidCircleEffect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class LiquidCircleEffect : LiquidLoadEffect {
override func setupShape() -> [LiquittableCircle] {
return Array(0..<NumberOfCircles).map { i in
let angle = CGFloat(i) * CGFloat(2 * M_PI) / 8.0
let frame = self.loader!.frame
let center = CGMath.circlePoint(frame.center.minus(frame.origin), radius: self.radius, rad: angle)
let frame = self.loader.frame
let center = CGMath.circlePoint(frame.center.minus(frame.origin), radius: self.radius - self.circleRadius, rad: angle)
return LiquittableCircle(
center: center,
radius: self.circleRadius,
Expand All @@ -39,7 +39,7 @@ class LiquidCircleEffect : LiquidLoadEffect {
let frame = self.loader!.frame.center.minus(self.loader!.frame.origin)
return CGMath.circlePoint(
frame,
radius: self.radius,
radius: self.radius - self.circleRadius,
rad: self.key * CGFloat(2 * M_PI)
)
}
Expand All @@ -54,7 +54,7 @@ class LiquidCircleEffect : LiquidLoadEffect {
}

override func willSetup() {
self.circleRadius = loader.frame.width * 0.1
self.circleRadius = loader.frame.width * 0.09
self.circleScale = 1.10
self.engine = SimpleCircleLiquidEngine(radiusThresh: self.circleRadius * 0.85, angleThresh: 0.5)
let moveCircleRadius = circleRadius * moveScale
Expand Down
12 changes: 8 additions & 4 deletions Pod/Classes/LiquidLineEffect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ class LiquidLineEffect : LiquidLoadEffect {
}

override func movePosition(key: CGFloat) -> CGPoint {
return CGPoint(
x: loader.frame.width * sineTransform(key),
y: loader.frame.height * 0.5
)
if loader != nil {
return CGPoint(
x: loader.frame.width * sineTransform(key),
y: loader.frame.height * 0.5
)
} else {
return CGPointZero
}
}

func sineTransform(key: CGFloat) -> CGFloat {
Expand Down
30 changes: 24 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
# LiquidLoader
LiquidLoader is the loader UI components with liquid animation, inspired by [Spinner Loader - Gooey light Effect](http:https://www.materialup.com/posts/spinner-loader-gooey-light-effect)

[![CI Status](http:https://img.shields.io/travis/Takuma Yoshida/LiquidLoader.svg?style=flat)](https://travis-ci.org/Takuma Yoshida/LiquidLoader)
[![Version](https://img.shields.io/cocoapods/v/LiquidLoader.svg?style=flat)](http:https://cocoapods.org/pods/LiquidLoader)
[![License](https://img.shields.io/cocoapods/l/LiquidLoader.svg?style=flat)](http:https://cocoapods.org/pods/LiquidLoader)
[![Platform](https://img.shields.io/cocoapods/p/LiquidLoader.svg?style=flat)](http:https://cocoapods.org/pods/LiquidLoader)

## GrowCircle
![GrowCircle](https://github.com/yoavlt/LiquidLoader/blob/master/Demo/grow-circle.gif?raw=true)

## GrowLine
![GrowLine](https://github.com/yoavlt/LiquidLoader/blob/master/Demo/grow-line.gif?raw=true)


## Usage

To run the example project, clone the repo, and run `pod install` from the Example directory first.
```swift:
let loader = LiquidLoader(frame: loaderFrame, effect: .GrowCircle(circleColor))
view.addSubview(loader)
```

## Requirements
### Show/Hide

```swift:
loader.show()
loader.hide()
```

### Effect Type
You can use the following effects.
* .GrowCircle
* .GrowLine
* .Circle
* .Line

If you avoid grow effect, you should use `.Circle` and `.Line`.

## Installation

Expand All @@ -23,10 +45,6 @@ it, simply add the following line to your Podfile:
pod "LiquidLoader"
```

## Author

Takuma Yoshida, [email protected]

## License

LiquidLoader is available under the MIT license. See the LICENSE file for more info.

0 comments on commit 28fbec4

Please sign in to comment.