Skip to content

Commit 2956ba5

Browse files
committed
Update demo.
1 parent dbe95d9 commit 2956ba5

File tree

1 file changed

+39
-23
lines changed

1 file changed

+39
-23
lines changed

TXScrollLabelViewDemo/TXScrollLabelViewDemo/ViewController.m

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#import "ViewController.h"
1010
#import "TXScrollLabelView.h"
1111

12-
@interface ViewController ()
12+
@interface ViewController ()<TXScrollLabelViewDelegate>
1313

1414
@property (weak, nonatomic) TXScrollLabelView *scrollLabelView;
1515

@@ -34,29 +34,45 @@ - (void)setViewInfos {
3434

3535
- (void)setSubviews {
3636

37-
for (int options = 0; options < 4; ++ options) {
38-
NSString *scrollTitle = @"If you don't control the image server you're using, you may not be able to change the URL when its content is updated. This is the case for Facebook avatar URLs for instance. In such case, you may use the SDWebImageRefreshCached flag. This will slightly degrade the performance but will respect the HTTP caching control headers";
39-
//options 是 TXScrollLabelViewType 枚举类型, 此处仅为了方便举例
40-
TXScrollLabelView *scrollLabelView = [TXScrollLabelView scrollWithTitle:scrollTitle type:options velocity:3 options:UIViewAnimationOptionTransitionFlipFromTop];
41-
[self.view addSubview:scrollLabelView];
42-
43-
//布局(Required)
44-
scrollLabelView.frame = CGRectMake(50, 100 * (options + 0.7), 300, 30);
45-
46-
//偏好(Optional)
47-
scrollLabelView.tx_centerX = [UIScreen mainScreen].bounds.size.width * 0.5;
48-
scrollLabelView.scrollInset = UIEdgeInsetsMake(0, 10 , 0, 10);
49-
scrollLabelView.scrollSpace = 10;
50-
scrollLabelView.font = [UIFont systemFontOfSize:15];
51-
scrollLabelView.textAlignment = NSTextAlignmentCenter;
52-
scrollLabelView.backgroundColor = [UIColor blackColor];
53-
scrollLabelView.layer.cornerRadius = 5;
54-
55-
//开始滚动
56-
[scrollLabelView beginScrolling];
57-
self.scrollLabelView = scrollLabelView;
58-
}
37+
[self addWith:TXScrollLabelViewTypeLeftRight velocity:0.4];
38+
39+
[self addWith:TXScrollLabelViewTypeUpDown velocity:1];
40+
41+
[self addWith:TXScrollLabelViewTypeFlipRepeat velocity:2];
42+
43+
[self addWith:TXScrollLabelViewTypeFlipNoRepeat velocity:2];
44+
}
45+
46+
- (void)addWith:(TXScrollLabelViewType)type velocity:(CGFloat)velocity {
47+
/** Step1: 滚动文字 */
48+
NSString *scrollTitle = @"If you don't control the image server you're using, you may not be able to change the URL when its content is updated. This is the case for Facebook avatar URLs for instance. In such case, you may use the SDWebImageRefreshCached flag. This will slightly degrade the performance but will respect the HTTP caching control headers";
49+
50+
/** Step2: 创建 ScrollLabelView */
51+
TXScrollLabelView *scrollLabelView = [TXScrollLabelView scrollWithTitle:scrollTitle type:type velocity:velocity options:UIViewAnimationOptionCurveEaseInOut];
52+
53+
/** Step3: 设置代理进行回调 */
54+
scrollLabelView.scrollLabelViewDelegate = self;
55+
56+
/** Step4: 布局(Required) */
57+
scrollLabelView.frame = CGRectMake(50, 100 * (type + 0.7), 300, 30);
58+
59+
[self.view addSubview:scrollLabelView];
60+
61+
//偏好(Optional), Preference,if you want.
62+
scrollLabelView.tx_centerX = [UIScreen mainScreen].bounds.size.width * 0.5;
63+
scrollLabelView.scrollInset = UIEdgeInsetsMake(0, 10 , 0, 10);
64+
scrollLabelView.scrollSpace = 10;
65+
scrollLabelView.font = [UIFont systemFontOfSize:15];
66+
scrollLabelView.textAlignment = NSTextAlignmentCenter;
67+
scrollLabelView.backgroundColor = [UIColor blackColor];
68+
scrollLabelView.layer.cornerRadius = 5;
69+
70+
/** Step5: 开始滚动(Start scrolling!) */
71+
[scrollLabelView beginScrolling];
5972
}
6073

74+
- (void)scrollLabelView:(TXScrollLabelView *)scrollLabelView didClickWithText:(NSString *)text{
75+
NSLog(@"%@",text);
76+
}
6177

6278
@end

0 commit comments

Comments
 (0)