DPScrollNumberLabel.h
10.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
//
// DPScrollNumberLabel.h
// DPScrollNumberLabelDemo
//
// Created by Dai Pei on 16/5/23.
// Copyright © 2016年 Dai Pei. All rights reserved.
//
#import <UIKit/UIKit.h>
/**
The setting option for SignSetting
- SignSettingUnsigned: only display positive number, default configuration is unsigned
- SignSettingNormal: negative numbers have negative sign but positive numbers don't have sign
- SignSettingSigned: positive numbers have sign as well as negative numbers
- default: SignSettingUnsigned
*/
typedef NS_ENUM(NSUInteger, SignSetting) {
SignSettingUnsigned,
SignSettingNormal,
SignSettingSigned
};
@interface DPScrollNumberLabel : UIView
/**
It synchronize with the value you set by method '-changeToNumber:animated:' and '-changeToNumber:interval:animated:'
*/
@property (nonatomic, strong, readonly)NSNumber *currentNumber;
/**
This property control the minimum display row.
if set this property to 2, and currentNumber is 1, the display is 01
*/
@property (nonatomic, assign)NSUInteger minRowNumber;
/**
Dynamic init method, the instance created by this method have a dynamic row count, it's row will change with the value you setting
@param number the initial number you want to display
@param fontSize the number font size you want
@return the instance of DPScrollNumberLabel
*/
- (instancetype)initWithNumber:(NSNumber *)number fontSize:(CGFloat)fontSize;
/**
Dynamic init method, the instance created by this method have a dynamic row count, it's row will change with the value you setting
@param number the initial number you want to display
@param fontSize the number font size you want
@param textColor the number color you want
@return the instance of DPScrollNumberLabel
*/
- (instancetype)initWithNumber:(NSNumber *)number fontSize:(CGFloat)fontSize textColor:(UIColor *)textColor;
/**
Dynamic init method, the instance created by this method have a dynamic row count, it's row will change with the value you setting
@param number the initial number you want to display
@param fontSize the number font size you want
@param signSetting the sign setting for DPScrollNumberLabel, you have three option: unsigned, normal, signed. see SignSetting enum declaration for detail.
@return the instance of DPScrollNumberLabel
*/
- (instancetype)initWithNumber:(NSNumber *)number fontSize:(CGFloat)fontSize signSetting:(SignSetting)signSetting;
/**
Dynamic init method, the instance created by this method have a dynamic row count, it's row will change with the value you setting
@param number the initial number you want to display
@param fontSize the number font size you want
@param textColor the number color you want
@param signSetting the sign setting for DPScrollNumberLabel, you have three option: unsigned, normal, signed. see SignSetting enum declaration for detail.
@return the instance of DPScrollNumberLabel
*/
- (instancetype)initWithNumber:(NSNumber *)number fontSize:(CGFloat)fontSize textColor:(UIColor *)textColor signSetting:(SignSetting)signSetting;
/**
Dynamic init method, the instance created by this method have a dynamic row count, it's row will change with the value you setting
@param number the initial number you want to display
@param font the number font you want
@return the instance of DPScrollNumberLabel
*/
- (instancetype)initWithNumber:(NSNumber *)number font:(UIFont *)font;
/**
Dynamic init method, the instance created by this method have a dynamic row count, it's row will change with the value you setting
@param number the initial number you want to display
@param font the number font you want
@param textColor the number color you want
@return the instance of DPScrollNumberLabel
*/
- (instancetype)initWithNumber:(NSNumber *)number font:(UIFont *)font textColor:(UIColor *)textColor;
/**
Dynamic init method, the instance created by this method have a dynamic row count, it's row will change with the value you setting
@param number the initial number you want to display
@param font the number font you want
@param signSetting the sign setting for DPScrollNumberLabel, you have three option: unsigned, normal, signed. see SignSetting enum declaration for detail.
@return the instance of DPScrollNumberLabel
*/
- (instancetype)initWithNumber:(NSNumber *)number font:(UIFont *)font signSetting:(SignSetting)signSetting;
/**
Dynamic init method, the instance created by this method have a dynamic row count, it's row will change with the value you setting
@param number the initial number you want to display
@param font the number font you want
@param textColor the number color you want
@param signSetting the sign setting for DPScrollNumberLabel, you have three option: unsigned, normal, signed. see SignSetting enum declaration for detail.
@return the instance of DPScrollNumberLabel
*/
- (instancetype)initWithNumber:(NSNumber *)number font:(UIFont *)font textColor:(UIColor *)textColor signSetting:(SignSetting)signSetting;
/*-------------------------------------------- Dynamic init method end -------------------------------------------------
If you set row number, the DPScrollNumberLabel instance's max num will less than the row num.
For example, you set row number to 1, then the max count of this label will be 9.
Note:rowNumber shouldn't more than 8
---------------------------------------------- Static init method start -----------------------------------------------*/
/**
Static init method, the instance created by this method have a comfirmed row count,
if your value's row bigger than the comfirmed row, it won't have effect
@param number the initial number you want to display
@param fontSize the number font size you want
@param rowNumber the row count of DPScrollNumberLabel, it means the row count will be changeless
@return the instance of DPScrollNumberLabel
*/
- (instancetype)initWithNumber:(NSNumber *)number
fontSize:(CGFloat)fontSize
rowNumber:(NSUInteger)rowNumber;
/**
Static init method, the instance created by this method have a comfirmed row count,
if your value's row bigger than the comfirmed row, it won't have effect
@param number the initial number you want to display
@param fontSize the number font size you want
@param textColor the number color you want
@param rowNumber the row count of DPScrollNumberLabel, it means the row count will be changeless
@return the instance of DPScrollNumberLabel
*/
- (instancetype)initWithNumber:(NSNumber *)number
fontSize:(CGFloat)fontSize
textColor:(UIColor *)textColor
rowNumber:(NSUInteger)rowNumber;
/**
Static init method, the instance created by this method have a comfirmed row count,
if your value's row bigger than the comfirmed row, it won't have effect
@param number the initial number you want to display
@param fontSize the number font size you want
@param signSetting the sign setting for DPScrollNumberLabel, you have three option: unsigned, normal, signed. see SignSetting enum declaration for detail.
@param rowNumber the row count of DPScrollNumberLabel, it means the row count will be changeless
@return the instance of DPScrollNumberLabel
*/
- (instancetype)initWithNumber:(NSNumber *)number
fontSize:(CGFloat)fontSize
signSetting:(SignSetting)signSetting
rowNumber:(NSUInteger)rowNumber;
/**
Static init method, the instance created by this method have a comfirmed row count,
if your value's row bigger than the comfirmed row, it won't have effect
@param number the initial number you want to display
@param fontSize the number font size you want
@param textColor the number color you want
@param signSetting the sign setting for DPScrollNumberLabel, you have three option: unsigned, normal, signed. see SignSetting enum declaration for detail.
@param rowNumber the row count of DPScrollNumberLabel, it means the row count will be changeless
@return the instance of DPScrollNumberLabel
*/
- (instancetype)initWithNumber:(NSNumber *)number
fontSize:(CGFloat)fontSize
textColor:(UIColor *)textColor
signSetting:(SignSetting)signSetting
rowNumber:(NSUInteger)rowNumber;
/**
Static init method, the instance created by this method have a comfirmed row count,
if your value's row bigger than the comfirmed row, it won't have effect
@param number the initial number you want to display
@param font the number font you want
@param textColor the number color you want
@param rowNumber the row count of DPScrollNumberLabel, it means the row count will be changeless
@return the instance of DPScrollNumberLabel
*/
- (instancetype)initWithNumber:(NSNumber *)number
font:(UIFont *)font
textColor:(UIColor *)textColor
rowNumber:(NSUInteger)rowNumber;
/**
Static init method, the instance created by this method have a comfirmed row count,
if your value's row bigger than the comfirmed row, it won't have effect
@param number the initial number you want to display
@param font the number font you want
@param signSetting the sign setting for DPScrollNumberLabel, you have three option: unsigned, normal, signed. see SignSetting enum declaration for detail.
@param rowNumber the row count of DPScrollNumberLabel, it means the row count will be changeless
@return the instance of DPScrollNumberLabel
*/
- (instancetype)initWithNumber:(NSNumber *)number
font:(UIFont *)font
signSetting:(SignSetting)signSetting
rowNumber:(NSUInteger)rowNumber;
/**
Static init method, the instance created by this method have a comfirmed row count,
if your value's row bigger than the comfirmed row, it won't have effect
@param number the initial number you want to display
@param font the number font you want
@param textColor the number color you want
@param signSetting the sign setting for DPScrollNumberLabel, you have three option: unsigned, normal, signed. see SignSetting enum declaration for detail.
@param rowNumber the row count of DPScrollNumberLabel, it means the row count will be changeless
@return the instance of DPScrollNumberLabel
*/
- (instancetype)initWithNumber:(NSNumber *)number
font:(UIFont *)font
textColor:(UIColor *)textColor
signSetting:(SignSetting)signSetting
rowNumber:(NSUInteger)rowNumber;
/**
When you want to change the display value, you can use this method,
and the interval of scroll animation will be calculated automatically
@param number the number you want to display
@param animated if you pass NO, the label will display your number without animation
*/
- (void)changeToNumber:(NSNumber *)number animated:(BOOL)animated;
/**
When you want to change the display value and you want to calculate
the animation interval by yourself, you should use this method
@param number the number you want to display
@param interval the animation interval
@param animated if you pass NO, the label will display your number withour animation
*/
- (void)changeToNumber:(NSNumber *)number interval:(CGFloat)interval animated:(BOOL)animated;
@end