Get Updates By E-mail 

Article Written By:
Johann Dowa

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.


Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.