iOS App Development Book/Video Series

General Category => FAQs => Topic started by: kjmcneish on September 15, 2015, 03:51:57 AM

Title: How to execute code after a UIImageView animation completes--without timers!
Post by: kjmcneish on September 15, 2015, 03:51:57 AM
I found a great little extension to UIImageView that allows you to specify a block to be executed after the UIImageView animation is complete. Unlike other solutions that use a timer (bad idea). It uses CAKeyframeAnimation instead, with its animationDidStop method, which is far more reliable:

https://github.com/gurmundi7/UIImageView-AnimationCompletionBlock (https://github.com/gurmundi7/UIImageView-AnimationCompletionBlock)

It's written in Objective-C, so you Swifters just need to add it to your project and then import it in your bridging header file:

Code: [Select]
#import "UIImageView+AnimationCompletion.h"
All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11 (https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11)