Author Topic: How to execute code after a UIImageView animation completes--without timers!  (Read 4582 times)

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
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

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
« Last Edit: September 15, 2015, 03:54:37 AM by kjmcneish »