[go: up one dir, main page]

Skip to content
forked from remirobert/Anim

Animation library, using Core Animation. Designed for iOS.

License

Notifications You must be signed in to change notification settings

nvnguyenit/Anim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

let animation = Animation.movePosition(CGPointMake(30, 30), delay: 1.5)
self.myView.layer.runAnimation(animation)

You can use the block completion for link animation

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.

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.

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:

self.myView.layer.removeAllAnimations()

Example

Here are some example of use:

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
        })
      })
    })
  })
})

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)

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.

About

Animation library, using Core Animation. Designed for iOS.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%