-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHLProgressView.h
executable file
·345 lines (304 loc) · 11.5 KB
/
HLProgressView.h
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
//
// HLProgressView.h
// HLProgressViewDemo
//
// Created by MrUncle on 15/3/3.
// Copyright © 2015年 MrUncle. All rights reserved.
//
#import <CoreGraphics/CoreGraphics.h>
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
// Global
#define HLProgressViewDefaultStripeWidth 7 //px
#define HLProgressViewDefaultStripeDelta 8 //px
/**
* The progress bar appearance.
*/
typedef NS_ENUM (NSUInteger, HLProgressViewType)
{
/**
* The progress bar has rounded corners and the gloss effect by default.
*/
HLProgressViewTypeRounded = 0,
/**
* The progress bar has squared corners and no gloss.
*/
HLProgressViewTypeFlat = 1,
};
/**
* The stripes orientation.
*/
typedef NS_ENUM (NSUInteger, HLProgressViewStripesOrientation)
{
/**
* The stripes are obliques in the north-west direction.
*/
HLProgressViewStripesOrientationRight = 0,
/**
* The stripes are obliques in the south-west direction.
*/
HLProgressViewStripesOrientationLeft = 1,
/**
* The stripes are verticals.
*/
HLProgressViewStripesOrientationVertical = 2,
};
/**
* The stripes movement direction.
*/
typedef NS_ENUM (NSInteger, HLProgressViewStripesDirection)
{
/**
* The stripes go from right to left.
*/
HLProgressViewStripesDirectionLeft = -1,
/**
* The stripes go from left to right.
*/
HLProgressViewStripesDirectionRight = 1
};
/**
* The behavior of a progress bar.
*/
typedef NS_ENUM (NSUInteger, HLProgressViewBehavior)
{
/**
* The default behavior of a progress bar. This mode is identical to the
* UIProgressView.
*/
HLProgressViewBehaviorDefault = 0,
/**
* The indeterminate behavior display the stripes when the progress value is
* equal to 0 only. This mode is helpful when percentage is not yet known,
* but will be known shortly.
*/
HLProgressViewBehaviorIndeterminate = 1,
/**
* The waiting behavior display the stripes when the progress value is equal
* to 1 only.
*/
HLProgressViewBehaviorWaiting = 2,
};
/**
* The display mode of the indicator text.
*/
typedef NS_ENUM (NSUInteger, HLProgressViewIndicatorTextDisplayMode)
{
/**
* The indicator text is not displayed.
*/
HLProgressViewIndicatorTextDisplayModeNone = 0,
/**
* The indicator text is displayed over the track bar and below the progress
* bar.
*/
HLProgressViewIndicatorTextDisplayModeTrack = 1,
/**
* The indicator text is diplayed over the progress bar.
*/
HLProgressViewIndicatorTextDisplayModeProgress = 2,
};
/**
* The HLProgressView is an UIProgressView replacement with an highly and fully
* customizable animated progress bar.
*
* The HLProgressView class provides properties for managing the style of the
* track and the progress bar, managun its behavior and for getting and setting
* values that are pinned to the progress of a task.
*
* Unlike the UIProgressView, the HLProgressView can be used for as an
* indeterminate progress indicator thanks to its pre-made behaviors.
*
* <em>Note: The HLProgressView is conform to the UIAppearance protocol, however,
* because of the current version of the appledoc project, the
* UI_APPEARANCE_SELECTOR macros are not taken into account, that's why they
* are commented.</em>
*/
IB_DESIGNABLE @interface HLProgressView : UIView
#pragma mark Managing the Progress Bar
/** @name Managing the Progress Bar */
/**
* @abstract The current progress shown by the receiver.
* @discussion The current progress is represented by a floating-point value
* between 0.0 and 1.0, inclusive, where 1.0 indicates the completion of the
* task.
*
* The default value is 0.3. Values less than 0.0 and greater than 1.0 are
* pinned to those limits.
*/
@property (atomic, assign) IBInspectable CGFloat progress;
/**
* @abstract Adjusts the current progress shown by the receiver, optionally
* animating the change.
* @param progress The new progress value.
* @param animated YES if the change should be animated, NO if the change should
* happen immediately.
* @discussion The current progress is represented by a floating-point value
* between 0.0 and 1.0, inclusive, where 1.0 indicates the completion of the
* task.
* The default value is 0.0. Values less than 0.0 and greater than 1.0 are
* pinned to those limits.
*/
- (void)setProgress:(CGFloat)progress animated:(BOOL)animated;
#pragma mark Modifying the Progress Bar’s Behavior
/** @name Modifying the Progress Bar’s Behavior */
/**
* @abstract The behavior of the progress bar.
* A behavior defines how the progress bar needs to react in certain cases.
* For example the "default" behavior of the progress bar displays the stripes
* everytime whereas the "waiting" behavior displays them only when the
* progress value is nearby the max value.
*
* @discussion The default value is HLProgressViewBehaviorDefault.
*/
@property (nonatomic, assign) IBInspectable HLProgressViewBehavior behavior; //UI_APPEARANCE_SELECTOR;
#pragma mark Configuring the Progress Bar
/** @name Configuring the Progress Bar */
/**
* @abstract A Boolean value that determines whether the gloss effet (outer and
* inner one) is hidden.
* @discussion Setting the value of this property to YES hides the gloss effect
* and setting it to NO shows the gloss effect whatever the progress type
* (`HLProgressViewTypeRounded` or `HLProgressViewTypeFlat`). The value is updated
* each time the type change.
*/
@property (nonatomic, assign) IBInspectable BOOL hideGloss;
/**
* @abstract A Boolean value that determines whether the progress bar needs
* stretch when the value change.
* @discussion Setting the value of this property to YES means that the colors
* of the `progressTintColors` is stretched.
*
* For example the `progressTintColors` is equal to `[blue, yellow, red]` and
* the `value` is set to 50%.
* If the progress bar is stretch the progress bar looks like that:
* `|-blue.yellow.red-----------|`
* Otherwise it should looks like that:
* `|-blue.....yellow-----------|`
*
* The default value is set to YES.
*/
@property (nonatomic, assign) IBInspectable BOOL progressStretch;
/**
* @abstract The colors shown for the portion of the progress bar
* that is filled.
* @discussion All the colors in the array are drawn as a gradient
* visual of equal size.
*/
@property (nonatomic, strong) NSArray *progressTintColors; //UI_APPEARANCE_SELECTOR;
/**
* @abstract The color shown for the portion of the progress bar that is filled.
*/
@property (nonatomic, strong) IBInspectable UIColor *progressTintColor; //UI_APPEARANCE_SELECTOR;
/**
* @abstract The color shown for the portion of the progress bar that is not
* filled.
*/
@property (nonatomic, strong) IBInspectable UIColor *trackTintColor; //UI_APPEARANCE_SELECTOR;
/**
* @abstract A CGFloat value that determines the inset between the track and the
* progressBar for the rounded progress bar type.
* @discussion The default value is 1px.
*/
@property (nonatomic, assign) IBInspectable CGFloat progressBarInset; //UI_APPEARANCE_SELECTOR;
/**
* @abstract The type of the progress bar.
* @discussion The default value is set to `HLProgressViewTypeRounded`. The corner
* radius can be configured through the `cornerRadius` property.
*/
@property (nonatomic, assign) IBInspectable HLProgressViewType type; //UI_APPEARANCE_SELECTOR;
/**
* @abstract The corner radius of the progress bar.
* @discussion The default value is 0. It means that the corner radius is equal
* to the half of the height.
*/
@property (nonatomic, assign) IBInspectable CGFloat cornerRadius; //UI_APPEARANCE_SELECTOR;
/**
* @abstract Animation time
* @discussion The default value is 1.f
*/
@property (nonatomic, assign) IBInspectable NSTimeInterval progressBarProgressTime; //UI_APPEARANCE_SELECTOR;
#pragma mark Displaying Text
/** @name Displaying Text */
/**
* @abstract A label to display some indications for the user.
* When the label text is set to nil it shows the progress value as a percentage
* You can configure its font color, the font size, the text alignement, etc. as
* any other labels.
* @discussion By default the label text is set to nil and its text color change
* using the background color.
*/
@property (nonatomic, strong) UILabel *indicatorTextLabel;
/**
* @abstract The display indicator text mode. It defines where the indicator
* text needs to display.
* @discussion The default value is set to
* `HLProgressViewIndicatorTextDisplayModeNone`.
*/
@property (nonatomic, assign) IBInspectable HLProgressViewIndicatorTextDisplayMode indicatorTextDisplayMode; //UI_APPEARANCE_SELECTOR;
#pragma mark Configuring the Stripes
/** @name Configuring the Stripes */
/**
* @abstract The animated vs. nonanimated stripes of the progress bar.
* @discussion If YES, the stripes over the progress bar is moving from the left
* to the right side.
*
* The default value for this property is YES.
*/
@property (nonatomic, getter = isStripesAnimated) IBInspectable BOOL stripesAnimated;
/**
* @abstract The direction of the movement during the animation.
* @discussion The default value for this property is
* `HLProgressViewStripesDirectionRight`.
*/
@property (nonatomic, assign) IBInspectable HLProgressViewStripesDirection stripesDirection; //UI_APPEARANCE_SELECTOR;
/**
* @abstract The velocity of the stripes during the animation. Higher is the
* value, greater the distance traveled by the stripes during a frame is.
* @discussion The absolute value of the property is taken into account. By
* default the velocity is `1`.
*/
@property (nonatomic, assign) IBInspectable double stripesAnimationVelocity; //UI_APPEARANCE_SELECTOR;
/**
* @abstract The orientation of the stripes.
* @discussion The default value for this property is
* `HLProgressViewStripesOrientationRight`.
*/
@property (nonatomic, assign) IBInspectable HLProgressViewStripesOrientation stripesOrientation; //UI_APPEARANCE_SELECTOR;
/**
* @abstract The width of the stripes drawn over the progress bar.
* @discussion If the property is less or equal than 0 the sprites are hidden.
*
* The default value for this property is equal to the
* `HLProgressViewDefaultStripeWidth` value.
*/
@property (nonatomic, assign) IBInspectable NSInteger stripesWidth; //UI_APPEARANCE_SELECTOR;
/**
* @abstract The color show for the stripes over the progress bar.
*/
@property (nonatomic, strong) IBInspectable UIColor *stripesColor; //UI_APPEARANCE_SELECTOR;
/**
* @abstract The x-coordinate distance in pixels between the top point and the
* bottom point of a slanted stripe.
* @discussion Default value is `HLProgressViewDefaultStripeDelta`. Positive
* integers are expected for correct effect. Has no effect when
* stripesOrientation property is `HLProgressViewStripesOrientationVertical`.
*/
@property (nonatomic, assign) IBInspectable NSInteger stripesDelta; //UI_APPEARANCE_SELECTOR;
/**
* @abstract A Boolean value that determines whether the stripes are hidden.
* @discussion Setting the value of this property to YES hides the stripes and
* setting it to NO shows the stripes. The default value is NO.
*/
@property (nonatomic, assign) IBInspectable BOOL hideStripes;
/**
* @abstract A Boolean value that determines whether the track is hidden.
* @discussion Setting the value of this property to YES hides the track and
* setting it to NO shows the track. The default value is NO.
*/
@property (nonatomic, assign) IBInspectable BOOL hideTrack;
@end
//! Project version number for HLProgressView.
FOUNDATION_EXPORT double HLProgressViewVersionNumber;
//! Project version string for HLProgressView.
FOUNDATION_EXPORT const unsigned char HLProgressViewVersionString[];