iOS UIView Category Allowing You To Set Up Customizable Animation Properties

Previously I mentioned an excellent library allowing you to create UIView animations with a cleaner blocks based syntax.

Here’s another interesting library from Martin Kiss for working with UIView animations called UIView+AnimatedProperty. The main part of this library is a category, and allows you to create accessible properties that can be modified elsewhere in your code.

Here’s an included example that shows how this can work – notice how duration and timingFunction are set to variables defined in the library, and a custom property is set as the toValue.

        CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"cornerRadius"];

        // You can access duration and timing function is created for you from options
        animation.duration = [[UIView currentAnimation] duration];
        animation.timingFunction = [[UIView currentAnimation] timingFunction];

        animation.toValue = @(cornerRadius);
        animation.fillMode = kCAFillModeForwards;
        animation.removedOnCompletion = NO;
        [self.layer addAnimation:animation forKey:@"setCornerRadius:"];

Then you can simply set up the animation with:

[UIView animateWithDuration:5 animations:^{
    myView.cornerRadius = 50;
}];

You can find UIView-Animated Property on Github here.

A very clever UIView extensions.

DeliciousTwitterFacebookRedditLinkedInEmail

Original article: iOS UIView Category Allowing You To Set Up Customizable Animation Properties

©2013 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *