iOS Library To Drastically Cleanup UIView Animation Sequence Code With Blocks (Open Source)

If you’ve ever animated a UIView – then you know how it works.

If you’ve been developing on the iOS platform awhile you may remember that early on UIView animations would take a ton of code.  You would start the sequence and write separate method calls to set the delegate and callbacks.

Support for blocks with UIView animations was introduced in iOS 4 which made for far less typing, but the syntax could still become very ugly and still requires quite a bit of typing..

This libray provides a very elegant solution by using blocks so that you can drastically reduce the total amount of code.

Here’s an example showing how readable and concise the code is with the library:

[[AnimationSequence sequenceWithSteps:
[AnimationStep for:0.25 do:^{ self.imageView.alpha = 0.0; }], 
[AnimationStep for:0.25 do:^{ self.headline.alpha = 0.0; }], 
[AnimationStep for:0.25 do:^{ self.content.alpha = 0.0; }], 
[AnimationStep after:1.0 for:0.25 do:^{ self.headline.alpha = 1.0; }], 
[AnimationStep for:0.25 do:^{ self.content.alpha = 1.0; }], nil]  
run];

Quite an improvement!

You can find more on the creator’s website and download the library in the Github repository.

Via Alex Curylo

©2011 iPhone, iOS 5, iPad SDK Development Tutorial and Programming Tips. All Rights Reserved.

.

DeliciousTwitterTechnoratiFacebookLinkedInEmail


Leave a Reply

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