Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matthewcheok/Fluent
Swift animation made easy
https://github.com/matthewcheok/Fluent
Last synced: 3 months ago
JSON representation
Swift animation made easy
- Host: GitHub
- URL: https://github.com/matthewcheok/Fluent
- Owner: matthewcheok
- License: mit
- Created: 2015-09-05T07:50:23.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-13T09:24:37.000Z (almost 8 years ago)
- Last Synced: 2024-11-24T08:42:31.396Z (3 months ago)
- Language: Swift
- Homepage:
- Size: 178 KB
- Stars: 296
- Watchers: 10
- Forks: 12
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - Fluent - Swift animation made easy. (UI / Animation)
- awesome-ios-star - Fluent - Swift animation made easy. (UI / Animation)
README
![]()
Fluent 
======[](https://github.com/matthewcheok/Fluent)
[](https://github.com/matthewcheok/Fluent)Swift Animations made Easy
## Installation
- Add the following to your [`Podfile`](http://cocoapods.org/) and run `pod install`
```
pod 'Fluent', '~> 0.1'
```
- or add the following to your [`Cartfile`](https://github.com/Carthage/Carthage) and run `carthage update`
```
github "matthewcheok/Fluent"
```
- or clone as a git submodule,- or just copy files in the ```Fluent``` folder into your project.
## Using Fluent
Fluent makes writing animations declarative and chainable.
```
boxView
.animate(0.5)
.rotate(0.5)
.scale(2)
.backgroundColor(.blueColor())
.waitThenAnimate(0.5)
.scale(1)
.backgroundColor(.redColor())
```Simply call one of the animation methods, of which only `duration` is required:
- animate(duration: NSTimeInterval, velocity: CGFloat , damping: CGFloat, options: UIViewAnimationOptions)
- waitThenAnimate(duration: NSTimeInterval, velocity: CGFloat , damping: CGFloat, options: UIViewAnimationOptions)All common properties on `UIView` are supported:
- scale(factor: CGFloat)
- translate(x: CGFloat, y: CGFloat)
- rotate(cycles: CGFloat)
- backgroundColor(color: UIColor)
- alpha(alpha: CGFloat)
- frame(frame: CGRect)
- bounds(bounds: CGRect)
- center(center: CGPoint)There are also relative versions of the transforms:
- scaleBy(factor: CGFloat)
- translateBy(x: CGFloat, y: CGFloat)
- rotateBy(cycles: CGFloat)You may not mix absolute and relative transformations in the same animation.
### Using transforms
The order of the transformations are important!
To reverse the following:
```
boxView
.animate(1)
.translateBy(50, 50)
.rotateBy(0.5)
.scaleBy(2)
.backgroundColor(.blueColor())
.alpha(0.7)
```We need to undo the transformations in reverse or get weird results:
```
boxView
.animate(1)
.scaleBy(0.5)
.rotateBy(-0.5)
.translateBy(-50, -50)
.backgroundColor(.redColor())
```
## LicenseFluent is under the MIT license.