-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQZAutoScrollLabel.h
executable file
·74 lines (62 loc) · 2.5 KB
/
QZAutoScrollLabel.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
//
// QZAutoScrollLabel.h
// QZAutoScrollLabel
//
// Created by Stephen.
//
#import <UIKit/UIKit.h>
/// 滚动方向枚举
typedef NS_ENUM(NSInteger, QZAutoScrollDirection) {
QZAutoScrollDirectionRight,
QZAutoScrollDirectionLeft
};
@interface QZAutoScrollLabel : UIView <UIScrollViewDelegate>
@property (nonatomic) QZAutoScrollDirection scrollDirection;
/// Scroll speed in pixels per second, defaults to 30
@property (nonatomic) float scrollSpeed;
@property (nonatomic) NSTimeInterval pauseInterval; // defaults to 1.5
@property (nonatomic) NSInteger labelSpacing; // pixels, defaults to 20
/**
* The animation options used when scrolling the UILabels.
* @discussion UIViewAnimationOptionAllowUserInteraction is always applied to the animations.
*/
@property (nonatomic) UIViewAnimationOptions animationOptions;
/**
* Returns YES, if it is actively scrolling, NO if it has paused or if text is within bounds (disables scrolling).
*/
@property (nonatomic, readonly) BOOL scrolling;
@property (nonatomic) CGFloat fadeLength; // defaults to 7
// UILabel properties
@property (nonatomic, strong, nonnull) UIFont *font;
@property (nonatomic, copy, nullable) NSString *text;
@property (nonatomic, copy, nullable) NSAttributedString *attributedText;
@property (nonatomic, strong, nonnull) UIColor *textColor;
@property (nonatomic) NSTextAlignment textAlignment; // only applies when not auto-scrolling
@property (nonatomic, strong, nullable) UIColor *shadowColor;
@property (nonatomic) CGSize shadowOffset;
/**
* Lays out the scrollview contents, enabling text scrolling if the text will be clipped.
* @discussion Uses [scrollLabelIfNeeded] internally.
*/
- (void)refreshLabels;
/**
* Set the text to the label and refresh labels, if needed.
* @discussion Useful when you have a situation where you need to layout the scroll label after it's text is set.
*/
- (void)setText:(nullable NSString *)text refreshLabels:(BOOL)refresh;
/**
Set the attributed text and refresh labels, if needed.
*/
- (void)setAttributedText:(nullable NSAttributedString *)theText refreshLabels:(BOOL)refresh;
/**
* Initiates auto-scroll, if the label width exceeds the bounds of the scrollview.
*/
- (void)scrollLabelIfNeeded;
/**
* Observes UIApplication state notifications to auto-restart scrolling and watch for
* orientation changes to refresh the labels.
* @discussion Must be called to observe the notifications. Calling multiple times will still only
* register the notifications once.
*/
- (void)observeApplicationNotifications;
@end