RBBAnimation
Block-based animations made easy, comes with easing functions and a CASpringAnimation replacement.
Top Related Projects
An extensible iOS and OS X animation library, useful for physics-based interactions.
An iOS library to natively render After Effects vector animations
Promises for Swift & ObjC.
MBProgressHUD + Customizations
:octocat: RAMAnimatedTabBarController is a Swift UI module library for adding animation to iOS tabbar items and icons. iOS library made by @Ramotion
A collection of animation examples for iOS apps.
Quick Overview
RBBAnimation is an iOS library that simplifies the process of creating complex animations. It provides a block-based interface for defining animations, allowing developers to create sophisticated, multi-step animations with ease. The library is designed to work seamlessly with UIKit and Core Animation.
Pros
- Simplifies complex animation creation with a block-based API
- Supports chaining multiple animations together
- Integrates well with existing UIKit and Core Animation frameworks
- Reduces boilerplate code for common animation tasks
Cons
- Limited documentation and examples
- Not actively maintained (last update was several years ago)
- May not be fully compatible with the latest iOS versions
- Lacks support for some advanced animation features
Code Examples
Creating a simple fade-in animation:
[UIView rbb_animateWithDuration:0.5 animations:^{
view.alpha = 1.0;
}];
Chaining multiple animations:
[UIView rbb_animate:^{
view.alpha = 1.0;
} completion:^{
[UIView rbb_animate:^{
view.frame = CGRectOffset(view.frame, 0, 100);
}];
}];
Creating a spring animation:
[UIView rbb_animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
view.center = CGPointMake(200, 200);
} completion:nil];
Getting Started
- Add the RBBAnimation folder to your Xcode project.
- Import the header file in your view controller:
#import "UIView+RBBAnimation.h"
- Use the RBBAnimation methods to create animations:
[UIView rbb_animateWithDuration:0.5 animations:^{
// Your animation code here
view.alpha = 0.5;
view.frame = CGRectOffset(view.frame, 50, 50);
}];
Competitor Comparisons
An extensible iOS and OS X animation library, useful for physics-based interactions.
Pros of Pop
- More comprehensive animation framework with a wider range of features
- Better performance, especially for complex animations
- Larger community and more extensive documentation
Cons of Pop
- Steeper learning curve due to its complexity
- Requires more setup and configuration
- Less intuitive API for simple animations
Code Comparison
RBBAnimation:
[UIView animateWithDuration:0.3 animations:^{
view.frame = newFrame;
}];
Pop:
POPSpringAnimation *anim = [POPSpringAnimation animationWithPropertyNamed:kPOPViewFrame];
anim.toValue = [NSValue valueWithCGRect:newFrame];
[view pop_addAnimation:anim forKey:@"frame"];
Summary
Pop offers a more powerful and flexible animation framework with better performance for complex animations. However, it comes with a steeper learning curve and requires more setup. RBBAnimation, on the other hand, provides a simpler and more intuitive API for basic animations but lacks the advanced features and performance optimizations of Pop.
The code comparison shows that RBBAnimation uses a more straightforward approach with UIView animations, while Pop requires more setup but offers finer control over animation properties.
Choose Pop for complex, high-performance animations in larger projects, and RBBAnimation for simpler animations in smaller projects or when rapid development is prioritized.
An iOS library to natively render After Effects vector animations
Pros of Lottie-iOS
- Supports complex animations created in Adobe After Effects
- Large community and extensive documentation
- Cross-platform compatibility (iOS, Android, Web)
Cons of Lottie-iOS
- Larger file size and potentially higher memory usage
- Steeper learning curve for designers and developers
- May require additional tools or plugins for creating animations
Code Comparison
RBBAnimation:
let animation = RBBTweenAnimation(keyPath: "position.x")
animation.fromValue = 0
animation.toValue = 100
animation.duration = 1.0
view.layer.addAnimation(animation, forKey: "move")
Lottie-iOS:
let animationView = AnimationView(name: "animation")
animationView.frame = view.bounds
animationView.contentMode = .scaleAspectFit
view.addSubview(animationView)
animationView.play()
Summary
Lottie-iOS offers more advanced animation capabilities and cross-platform support, making it suitable for complex projects. RBBAnimation provides a simpler, lightweight solution for basic animations with a smaller footprint. The choice between the two depends on the project's requirements, team expertise, and desired animation complexity.
Promises for Swift & ObjC.
Pros of PromiseKit
- Broader scope: Handles asynchronous programming and simplifies complex async operations
- More active development: Regular updates and a larger community
- Extensive documentation and examples available
Cons of PromiseKit
- Steeper learning curve for developers new to promises
- Potential performance overhead for simple tasks
- May be overkill for projects that don't require complex async operations
Code Comparison
PromiseKit:
firstly {
fetchUser()
}.then { user in
fetchAvatar(for: user)
}.done { avatar in
self.imageView.image = avatar
}.catch { error in
self.show(error)
}
RBBAnimation:
RBBTweenAnimation *animation = [RBBTweenAnimation animationWithKeyPath:@"position.x"];
animation.fromValue = @0;
animation.toValue = @100;
animation.duration = 0.3;
[layer addAnimation:animation forKey:@"slide"];
Summary
PromiseKit is a comprehensive solution for handling asynchronous operations in Swift and Objective-C, offering a powerful way to manage complex async tasks. RBBAnimation, on the other hand, is focused specifically on creating custom animations for iOS. While PromiseKit provides broader functionality and is more actively maintained, RBBAnimation offers a simpler, more targeted approach for animation tasks. The choice between the two depends on the specific needs of your project and the complexity of the asynchronous operations you need to handle.
MBProgressHUD + Customizations
Pros of MBProgressHUD
- Widely adopted and battle-tested in many iOS applications
- Offers a variety of pre-built HUD styles and animations out of the box
- Simple API for quick implementation of loading indicators and progress displays
Cons of MBProgressHUD
- Limited to HUD-style progress indicators and alerts
- Less flexibility for custom animations compared to RBBAnimation
- Primarily focused on iOS, while RBBAnimation is more platform-agnostic
Code Comparison
MBProgressHUD:
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeIndeterminate;
hud.label.text = @"Loading...";
[hud showAnimated:YES];
RBBAnimation:
CALayer *layer = [CALayer layer];
RBBTweenAnimation *animation = [RBBTweenAnimation animationWithKeyPath:@"position.x"];
animation.fromValue = @0;
animation.toValue = @100;
[layer addAnimation:animation forKey:@"move"];
RBBAnimation provides more granular control over animations, allowing developers to create custom animations for various UI elements. MBProgressHUD, on the other hand, offers a higher-level API specifically for creating progress indicators and HUDs with less customization but quicker implementation for common use cases.
:octocat: RAMAnimatedTabBarController is a Swift UI module library for adding animation to iOS tabbar items and icons. iOS library made by @Ramotion
Pros of animated-tab-bar
- More comprehensive and feature-rich, offering a variety of pre-built animations for tab bars
- Actively maintained with recent updates and a larger community
- Includes a demo app for easy testing and visualization of animations
Cons of animated-tab-bar
- Focused specifically on tab bar animations, less flexible for general-purpose use
- May have a steeper learning curve due to its more extensive feature set
- Potentially higher overhead for simple animation needs
Code Comparison
animated-tab-bar:
let tabBar = RAMAnimatedTabBarController()
let item1 = RAMAnimatedTabBarItem(title: "Home", image: UIImage(named: "home"), tag: 1)
item1.animation = RAMBounceAnimation()
tabBar.viewControllers = [homeViewController]
tabBar.animatedItems = [item1]
RBBAnimation:
RBBTweenAnimation *animation = [RBBTweenAnimation animationWithKeyPath:@"position.x"];
animation.fromValue = @0;
animation.toValue = @100;
animation.duration = 0.5;
[layer addAnimation:animation forKey:@"slide"];
Summary
animated-tab-bar is a specialized library for creating animated tab bars in iOS apps, offering a wide range of pre-built animations and an active community. RBBAnimation, on the other hand, is a more general-purpose animation library that provides greater flexibility but may require more manual setup. The choice between the two depends on the specific needs of your project and the desired level of customization.
A collection of animation examples for iOS apps.
Pros of popping
- More comprehensive collection of animation examples and techniques
- Includes a wider variety of animation types (e.g., transitions, transforms, keyframes)
- Better documentation and explanations for each animation technique
Cons of popping
- Less focused on a specific animation framework or methodology
- May be overwhelming for beginners due to the large number of examples
Code Comparison
RBBAnimation:
RBBSpringAnimation *animation = [RBBSpringAnimation animationWithKeyPath:@"position.y"];
animation.fromValue = @(view.center.y);
animation.toValue = @(view.center.y - 100);
animation.damping = 0.5;
animation.mass = 1.0;
popping:
POPSpringAnimation *anim = [POPSpringAnimation animationWithPropertyNamed:kPOPViewFrame];
anim.toValue = [NSValue valueWithCGRect:CGRectMake(0, 0, 100, 100)];
anim.springBounciness = 20.0f;
anim.springSpeed = 20.0f;
[view pop_addAnimation:anim forKey:@"spring"];
Both repositories focus on iOS animations, but RBBAnimation is more specialized in spring animations, while popping offers a broader range of animation techniques. RBBAnimation may be easier for beginners to grasp, while popping provides more options for advanced developers. The code examples show that both use similar concepts but with different syntax and property names.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
RBBAnimation
RBBAnimation
is a subclass of CAKeyframeAnimation
that allows you to
declare your animations using blocks instead of writing out all the
individual key-frames.
This gives you greater flexibility when specifying your animations while keeping your code concise.
It comes out of the box with a replacement for CASpringAnimation, support for custom easing functions such as bouncing as well as hooks to allow your writing your own animations fully from scratch.
Installation
To install RBBAnimation, I recommend the excellent CocoaPods. Simply add this to your Podfile
pod 'RBBAnimation', '0.4.0'
and you are ready to go!
If you'd like to run the bundled test app, make sure to install its dependencies by running
pod install
after cloning the repo.
RBBCustomAnimation
Use RBBCustomAnimation
to create arbitrary animations by passing in an
RBBAnimationBlock
:
RBBCustomAnimation *rainbow = [RBBCustomAnimation animationWithKeyPath:@"backgroundColor"];
rainbow.animationBlock = ^(CGFloat elapsed, CGFloat duration) {
UIColor *color = [UIColor colorWithHue:elapsed / duration
saturation:1
brightness:1
alpha:1];
return (id)color.CGColor;
};
The arguments of the block are the current position of the animation as well as its total duration.
Most of the time, you will probably want to use the higher-level
RBBTweenAnimation
.
RBBSpringAnimation
RBBSpringAnimation
is a handy replacement for the private CASpringAnimation.
Specify your spring's mass, damping, stiffness as well as its initial velocity
and watch it go:
RBBSpringAnimation *spring = [RBBSpringAnimation animationWithKeyPath:@"position.y"];
spring.fromValue = @(-100.0f);
spring.toValue = @(100.0f);
spring.velocity = 0;
spring.mass = 1;
spring.damping = 10;
spring.stiffness = 100;
spring.additive = YES;
spring.duration = [spring durationForEpsilon:0.01];
RBBTweenAnimation
RBBTweenAnimation
allows you to animate from one value to another, similar to
CABasicAnimation
but with a greater flexibility in how the values should be
interpolated.
It supports the same cubic Bezier interpolation that you get from
CAMediaTimingFunction
using the RBBCubicBezier
helper function:
RBBTweenAnimation *easeInOutBack = [RBBTweenAnimation animationWithKeyPath:@"position.y"];
easeInOutBack.fromValue = @(-100.0f);
easeInOutBack.toValue = @(100.0f);
easeInOutBack.easing = RBBCubicBezier(0.68, -0.55, 0.265, 1.55);
easeInOutBack.additive = YES;
easeInOutBack.duration = 0.6;
However, RBBTweenAnimation
also supports more complex easing functions such as
RBBEasingFunctionEaseOutBounce
:
RBBTweenAnimation *bounce = [RBBTweenAnimation animationWithKeyPath:@"position.y"];
bounce.fromValue = @(-100);
bounce.toValue = @(100);
bounce.easing = RBBEasingFunctionEaseOutBounce;
bounce.additive = YES;
bounce.duration = 0.8;
You can also specify your own easing functions, from scratch:
RBBTweenAnimation *sinus = [RBBTweenAnimation animationWithKeyPath:@"position.y"];
sinus.fromValue = @(0);
sinus.toValue = @(100);
sinus.easing = ^CGFloat (CGFloat fraction) {
return sin((fraction) * 2 * M_PI);
};
sinus.additive = YES;
sinus.duration = 2;
License
RBBAnimation was built by Robert Böhnke. It is licensed under the MIT License.
If you use RBBAnimation in one of your apps, I'd love to hear about it. Feel free to follow me on Twitter where I'm @ceterum_censeo.
Top Related Projects
An extensible iOS and OS X animation library, useful for physics-based interactions.
An iOS library to natively render After Effects vector animations
Promises for Swift & ObjC.
MBProgressHUD + Customizations
:octocat: RAMAnimatedTabBarController is a Swift UI module library for adding animation to iOS tabbar items and icons. iOS library made by @Ramotion
A collection of animation examples for iOS apps.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot