Latest 1.0.1
Homepage https://github.com/savvyapps/SAAnimationView
License MIT
Platforms ios 7.0, requires ARC
Frameworks UIKit
Authors

Pod Version
License

SAAnimationView is a framework that allows you to create an animation programatically. It uses a CADisplayLink to update every frame whenever the animation is not paused. Savvy Apps was initially inspired to create this framework by our work on an animation in a podcasting app for The Cato Institute. This framework doesn’t rely on images, making it easy to change and lessening the burden on the application size. Once the basic code is in place, adding and modifying the animation curve and timing is simple.

Features

  • Pause, resume and reverse the animation
  • Total control of the animation
  • The duration of the animation can be adjusted without causing the animation to stutter
  • Doesn’t use images, reducing the application size
  • Iterating on the animation is fast
  • No need to re-export animation when changes are made (or ever)

Considerations for use

  • Using multiple SAAnimationViews in your application at the same time might negatively affect the performance of you app
  • SAAnimationView is not an out-of-the-box solution, it requires you to implement the actual animation

Examples of use

Cato Audio Animation

Installation

SAAnimationView is available through [CocoaPods](http://cocoapods.org (http://cocoapods.org/)). To install
it, simply add the following line to your Podfile:

pod 'SAAnimationView'

How to use

Subclass SAAnimationView

To start using SAAnimationView, create a subclass of it and implement your animation logic. Below you will find two examples of simple animations.

@interface AnimationView : SAAnimationView

This example is a simple animation of an empty circle that is drawn gradually as the animation is executed.

- (void)drawRect:(CGRect)rect {
  UIBezierPath *circlePath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect))
                                                            radius:CGRectGetWidth(rect) / 2 - 3
                                                        startAngle:0 endAngle:(self.progress * 2 * M_PI) clockwise:NO];
  [circlePath stroke];
}

If you don’t want to draw your content using CoreGraphics, you can also use views to create an animation.
SAAnimationView has a method called update: that gets called every frame when the animation is not paused.

- (void)update:(CGFloat)delta {
  CGFloat scale = MAX(0.01, self.progress);
  self.imageView.transform = CGAffineTransformMakeScale(scale, scale);
}

Instantiate

You can instantiate your animation view with code like you would any other view, or through Interface Builder by adding a UIView element to your scene and setting the custom class to yours.

Initialize

The best way to initialize the properties of your view is to override initializeView and use it to set the properties, like behavior, duration, etc. If you want your application to start playing right away you can also do it here.

Authors / Contributions

SAAnimationView was authored by Emilio Peláez at Savvy Apps. We encourage feedback or pull requests.

License

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

Latest podspec

{
    "name": "SAAnimationView",
    "version": "1.0.1",
    "summary": "The SAAnimationView framework provides a simple interface to programmatically create an animation.",
    "description": "The SAAnimationView framework provides a simple interface to programmatically create an animation. It doesn't rely on images, giving it a few advantages over other animation frameworks. Because the framework draws the content with code instead of using images, it makes it simple to iterate on, doesn't require additional exports, and decreases the animation's burden on the size of the app.nRead more about SAAnimationView at http://savvyapps.com/blog/saanimationview-framework-programmatically-create-ios-animations",
    "homepage": "https://github.com/savvyapps/SAAnimationView",
    "license": "MIT",
    "authors": {
        "Emilio Pelau0301ez": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/savvyapps/SAAnimationView.git",
        "tag": "1.0.1"
    },
    "source_files": [
        "SAAnimationView",
        "SAAnimationView/**/*.{h,m}"
    ],
    "frameworks": "UIKit",
    "requires_arc": true
}

Pin It on Pinterest

Share This