Find file
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (24 sloc) 2.03 KB


I started implementing this class as part of one of the demos in the CoreAnimation class I gave in Madrid on July 2012 ( I decided to finish it and create a sample project with it.

NSBKeyframeAnimation allows you to create jQuery-like animations with a high level interface in a similar way as you would do with -[UIView animateWithDuration:delay:options:animations:completion:], but with any kind of function. You can animate any keypath between two values (for now they have to be scalar but I'll add support for any NSValue).



NSBKeyframeAnimation *animation = [NSBKeyframeAnimation animationWithKeyPath:@"position.x"

[view.layer setValue:animation.values.lastObject forKeyPath:@"position.x"];
[view.layer addAnimation:animation forKey:@"position.x"];

Future improvements

  • I'm working on a category to UIView to make using this class a much easier task. Coming soon!
  • I will add helper methods so that you can easily generate animations on the transform keypath and create really cool effects.

How To Use

  • Run git submodule add Dependencies/NSBKeyframeAnimation
  • Add Dependencies/NSBKeyframeAnimation/Classes/NSBKeyframeAnimation files to your project.
  • You're all set!


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