UICountingLabel.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #import <Foundation/Foundation.h>
  2. #import <UIKit/UIKit.h>
  3. typedef NS_ENUM(NSInteger, UILabelCountingMethod) {
  4. UILabelCountingMethodEaseInOut,
  5. UILabelCountingMethodEaseIn,
  6. UILabelCountingMethodEaseOut,
  7. UILabelCountingMethodLinear,
  8. UILabelCountingMethodEaseInBounce,
  9. UILabelCountingMethodEaseOutBounce
  10. };
  11. typedef NSString* (^UICountingLabelFormatBlock)(CGFloat value);
  12. typedef NSAttributedString* (^UICountingLabelAttributedFormatBlock)(CGFloat value);
  13. @interface UICountingLabel : UILabel
  14. @property (nonatomic, strong) NSString *format;
  15. @property (nonatomic, assign) UILabelCountingMethod method;
  16. @property (nonatomic, assign) NSTimeInterval animationDuration;
  17. @property (nonatomic, copy) UICountingLabelFormatBlock formatBlock;
  18. @property (nonatomic, copy) UICountingLabelAttributedFormatBlock attributedFormatBlock;
  19. @property (nonatomic, copy) void (^completionBlock)(void);
  20. -(void)countFrom:(CGFloat)startValue to:(CGFloat)endValue;
  21. -(void)countFrom:(CGFloat)startValue to:(CGFloat)endValue withDuration:(NSTimeInterval)duration;
  22. -(void)countFromCurrentValueTo:(CGFloat)endValue;
  23. -(void)countFromCurrentValueTo:(CGFloat)endValue withDuration:(NSTimeInterval)duration;
  24. -(void)countFromZeroTo:(CGFloat)endValue;
  25. -(void)countFromZeroTo:(CGFloat)endValue withDuration:(NSTimeInterval)duration;
  26. - (CGFloat)currentValue;
  27. @end