https://github.com/remirobert/anim
:eyes: Animation library, using Core Animation. Designed for iOS.
https://github.com/remirobert/anim
Last synced: 11 months ago
JSON representation
:eyes: Animation library, using Core Animation. Designed for iOS.
- Host: GitHub
- URL: https://github.com/remirobert/anim
- Owner: remirobert
- License: mit
- Created: 2014-10-09T14:29:03.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-08-30T16:31:05.000Z (almost 10 years ago)
- Last Synced: 2025-05-01T06:37:31.147Z (about 1 year ago)
- Language: Swift
- Homepage:
- Size: 1.47 MB
- Stars: 85
- Watchers: 7
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Anim
Anim allows you to use animations very easily. You can use it in your UIKit application for make smooth animations, using Swift.
Features
- Position (CGPoint)
- Bounce effect
- Resize (CGSize)
- Rotation
- Rotation X
- Rotation Y
- Rotation Z
- Fade
- Border raduis
- Move circle
- Animations sequence
- Repeat animations
- Block completion
How to use it
You can use Anim with all Layers (UIButton, UItableViewCell, UItextField, UIView, ...).
Anim provides a extension for CALayer, for use animation:
```Swift
let animation = Animation.movePosition(CGPointMake(30, 30), delay: 1.5)
self.myView.layer.runAnimation(animation)
```
You can use the block completion for link animation
```Swift
let resizeAnimation = Animation.resize(CGSizeMake(30, 30), delay: 1.5)
let bounceAnimation = Animation.bounce(30, delay: 0.1)
self.myView.layer.runAnimation(resizeAnimation, blockCompletion: { () -> () in
self.myView.layer.runAnimation(bounceAnimation)
})
```
You can also use sequence of animations. All animations in a sequence will be executed one after the other.
```Swift
let sequenceAnimation = Animation.sequenceAnimations([Animation.resize(CGSizeMake(30, 30), delay: 1.5),
Animation.bounce(30, delay: 0.1)])
self.myView.layer.runAnimation(sequenceAnimation)
```
Now there is the repeat animation method. For infinite or count animation.
```Swift
let move = Animation.sequenceAnimations([Animation.movePosition(CGPointMake(10, 10), delay: 1.5),
Animation.movePosition(CGPointMake(30, 30), delay: 1.5)])
let bounce = Animation.bounce(30, delay: 0.1)
let repeatBouceForEver = Animation.repeatAnimations(Repeat.Infinity, animationParam: bounce)
let repeatMove = Animation.repeatAnimations(Repeat.Count(10), animationParam: move)
self.myView.layer.runAnimation(repeatBouceForEver)
self.myView.layer.runAnimation(repeatMove)
```
For remove all current animation:
```Swift
self.myView.layer.removeAllAnimations()
```
Example
Here are some example of use:
```Swift
let animationStart = Animation.sequenceAnimations([Animation.resizeFrame(CGSizeMake(300, 300), delay: 2), Animation.rotationX(-0.85, delay: 2)])
o.layer.runAnimation(animationStart, blockCompletion: { () -> () in
self.l.layer.runAnimation(Animation.movePosition(CGPointMake(100, 100), delay: 2))
self.l.layer.runAnimation(Animation.resizeFrame(CGSizeMake(100, 100), delay: 2), blockCompletion: { () -> () in
self.l2.layer.runAnimation(Animation.movePosition(CGPointMake(110, 110), delay: 2))
self.l2.layer.runAnimation(Animation.resizeFrame(CGSizeMake(80, 80), delay: 2), blockCompletion: { () -> () in
self.l3.layer.runAnimation(Animation.movePosition(CGPointMake(120, 120), delay: 2))
self.l3.layer.runAnimation(Animation.resizeFrame(CGSizeMake(60, 60), delay: 2), blockCompletion: { () -> () in
o.layer.runAnimation(Animation.rotationX(0.85, delay: 2), blockCompletion: { () -> () in
})
})
})
})
})
```
```Swift
let a = Animation.repeatAnimations(Repeat.Count(3), animationParam: Animation.moveCircle(CGRectMake(0, 100, 200, 200), delay: 1))
let a2 = Animation.repeatAnimations(Repeat.Count(3), animationParam: Animation.moveCircle(CGRectMake(0, 100, 200, 200), delay: 1.5))
let a3 = Animation.repeatAnimations(Repeat.Count(3), animationParam: Animation.moveCircle(CGRectMake(0, 100, 200, 200), delay: 2))
l.layer.runAnimation(a)
l2.layer.runAnimation(a2)
l3.layer.runAnimation(a3)
```
```Swift
self.myImageView.layer.runAnimation(Animation.rotationY(Float(M_PI) * 4, delay: 2), blockCompletion: { () -> () in
self.myImageView.layer.runAnimation(Animation.bounce(60, delay: 0.1))
self.myImageView.image = UIImage(named: "otherImage")
})
```
Author
Rémi ROBERT, remirobert33530@gmail.com
Licence
Anim is available under the MIT license. See the LICENSE file for more info.