DKAnimatedImageView.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // FLAnimatedImageView.h
  3. // Flipboard
  4. //
  5. // Created by Raphael Schaad on 7/8/13.
  6. // Copyright (c) 2013-2014 Flipboard. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. @class DKAnimatedImage;
  10. @protocol DKAnimatedImageViewDebugDelegate;
  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 DKAnimatedImageView : 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) DKAnimatedImage *animatedImage;
  21. @property (nonatomic, strong, readonly) UIImage *currentFrame;
  22. @property (nonatomic, assign, readonly) NSUInteger currentFrameIndex;
  23. #if DEBUG
  24. // Only intended to report internal state for debugging
  25. @property (nonatomic, weak) id<DKAnimatedImageViewDebugDelegate> debug_delegate;
  26. #endif
  27. @end
  28. #if DEBUG
  29. @protocol DKAnimatedImageViewDebugDelegate <NSObject>
  30. @optional
  31. - (void)debug_animatedImageView:(DKAnimatedImageView *)animatedImageView waitingForFrame:(NSUInteger)index duration:(NSTimeInterval)duration;
  32. @end
  33. #endif