UICountingLabel.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  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. };
  9. typedef NSString* (^UICountingLabelFormatBlock)(CGFloat value);
  10. typedef NSAttributedString* (^UICountingLabelAttributedFormatBlock)(CGFloat value);
  11. @interface UICountingLabel : UILabel
  12. @property (nonatomic, strong) NSString *format;
  13. @property (nonatomic, assign) UILabelCountingMethod method;
  14. @property (nonatomic, assign) NSTimeInterval animationDuration;
  15. @property (nonatomic, copy) UICountingLabelFormatBlock formatBlock;
  16. @property (nonatomic, copy) UICountingLabelAttributedFormatBlock attributedFormatBlock;
  17. @property (nonatomic, copy) void (^completionBlock)(void);
  18. -(void)countFrom:(CGFloat)startValue to:(CGFloat)endValue;
  19. -(void)countFrom:(CGFloat)startValue to:(CGFloat)endValue withDuration:(NSTimeInterval)duration;
  20. -(void)countFromCurrentValueTo:(CGFloat)endValue;
  21. -(void)countFromCurrentValueTo:(CGFloat)endValue withDuration:(NSTimeInterval)duration;
  22. -(void)countFromZeroTo:(CGFloat)endValue;
  23. -(void)countFromZeroTo:(CGFloat)endValue withDuration:(NSTimeInterval)duration;
  24. - (CGFloat)currentValue;
  25. @end