FLAnimatedImageView.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // FLAnimatedImageView.h
  3. // Flipboard
  4. //
  5. // Created by Raphael Schaad on 7/8/13.
  6. // Copyright (c) 2013-2015 Flipboard. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. @class FLAnimatedImage;
  10. @protocol FLAnimatedImageViewDebugDelegate;
  11. //
  12. // An `FLAnimatedImageView` can take an `FLAnimatedImage` and plays it automatically when in view hierarchy and stops when removed.
  13. // The animation can also be controlled with the `UIImageView` methods `-start/stop/isAnimating`.
  14. // It is a fully compatible `UIImageView` subclass and can be used as a drop-in component to work with existing code paths expecting to display a `UIImage`.
  15. // Under the hood it uses a `CADisplayLink` for playback, which can be inspected with `currentFrame` & `currentFrameIndex`.
  16. //
  17. @interface FLAnimatedImageView : UIImageView
  18. // Setting `[UIImageView.image]` to a non-`nil` value clears out existing `animatedImage`.
  19. // And vice versa, setting `animatedImage` will initially populate the `[UIImageView.image]` to its `posterImage` and then start animating and hold `currentFrame`.
  20. @property (nonatomic, strong) FLAnimatedImage *animatedImage;
  21. @property (nonatomic, copy) void(^loopCompletionBlock)(NSUInteger loopCountRemaining);
  22. @property (nonatomic, strong, readonly) UIImage *currentFrame;
  23. @property (nonatomic, assign, readonly) NSUInteger currentFrameIndex;
  24. // The animation runloop mode. Enables playback during scrolling by allowing timer events (i.e. animation) with NSRunLoopCommonModes.
  25. // To keep scrolling smooth on single-core devices such as iPhone 3GS/4 and iPod Touch 4th gen, the default run loop mode is NSDefaultRunLoopMode. Otherwise, the default is NSDefaultRunLoopMode.
  26. @property (nonatomic, copy) NSString *runLoopMode;
  27. @end