BBACountingLabel.h 1.34 KB
//
//  BBACountingLabel.h
//  BBAUIKit
//
//  Created by chenjia09 on 2018/12/24.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

typedef NS_ENUM(NSInteger, BBALabelCountingMethod) {
    BBALabelCountingMethodEaseInOut,
    BBALabelCountingMethodEaseIn,
    BBALabelCountingMethodEaseOut,
    BBALabelCountingMethodLinear
};

typedef NSString* (^BBACountingLabelFormatBlock)(CGFloat value);
typedef NSAttributedString* (^BBACountingLabelAttributedFormatBlock)(CGFloat value);

@interface BBACountingLabel : UILabel

@property (nonatomic, strong) NSString *format;
@property (nonatomic, assign) BBALabelCountingMethod method;
@property (nonatomic, assign) NSTimeInterval animationDuration;

@property (nonatomic, copy) BBACountingLabelFormatBlock formatBlock;
@property (nonatomic, copy) BBACountingLabelAttributedFormatBlock attributedFormatBlock;
@property (nonatomic, copy) void (^completionBlock)(void);

-(void)countFrom:(CGFloat)startValue to:(CGFloat)endValue;
-(void)countFrom:(CGFloat)startValue to:(CGFloat)endValue withDuration:(NSTimeInterval)duration;

-(void)countFromCurrentValueTo:(CGFloat)endValue;
-(void)countFromCurrentValueTo:(CGFloat)endValue withDuration:(NSTimeInterval)duration;

-(void)countFromZeroTo:(CGFloat)endValue;
-(void)countFromZeroTo:(CGFloat)endValue withDuration:(NSTimeInterval)duration;

- (CGFloat)currentValue;

@end