- GitHub源碼:TXScrollLabelView
- star: 400+
??????
以下內(nèi)容來源于官方源碼、 README 文檔、測(cè)試 Demo或個(gè)人使用總結(jié) !
用法
/** Step1: 滾動(dòng)文字 */
NSString *scrollTitle = @"xxxxxx";
/** Step2: 創(chuàng)建 ScrollLabelView */
TXScrollLabelView *scrollLabelView = [TXScrollLabelView scrollWithTitle:scrollTitle type:TXScrollLabelViewTypeFlipNoRepeat velocity:velocity options:UIViewAnimationOptionCurveEaseInOut];
/** Step3: 設(shè)置代理進(jìn)行回調(diào)(Optional) */
scrollLabelView.scrollLabelViewDelegate = self;
/** Step4: 布局(Required) */
scrollLabelView.frame = CGRectMake(50, 100, 300, 30);
[self.view addSubview:scrollLabelView];
/** Step5: 開始滾動(dòng)(Start scrolling!) */
[scrollLabelView beginScrolling];
Demo:
// 滾動(dòng)Label
// step1:獲取滾動(dòng)內(nèi)容
NSString *scrollTitle = @"恭喜 XXX 網(wǎng)上商城隆重上線!";
// step2:創(chuàng)建scrollLabelView對(duì)象
TXScrollLabelView *scrollLabelView = [TXScrollLabelView scrollWithTitle:scrollTitle type:TXScrollLabelViewTypeFlipRepeat velocity:3 options:UIViewAnimationOptionTransitionNone];
scrollLabelView.backgroundColor = [UIColor clearColor];
scrollLabelView.scrollTitleColor = [UIColor blackColor];
// step3:設(shè)置代理進(jìn)行回調(diào)(Optional)
// scrollLabelView.scrollLabelViewDelegate = self;
// step4:布局
scrollLabelView.frame = CGRectMake(31, 31, 240, 21);
[self.view addSubview:scrollLabelView];
// [scrollLabelView mas_makeConstraints:^(MASConstraintMaker *make) {
// make.top.equalTo(speakerImage.mas_top);
// make.left.equalTo(speakerImage.mas_right).with.offset(0);
// make.size.mas_equalTo(CGSizeMake(240, 21));
// }];
// step5:開始滾動(dòng)
[scrollLabelView beginScrolling];
其他
Wonderful
這個(gè)框架里也有跑馬燈的兩個(gè)類,提取出來使用對(duì)于整個(gè)APP來說相比于這個(gè)框架更輕量簡(jiǎn)介些。使用:
CGRect rect = CGRectMake(31,31, 240, 21);
SXHeadLine *headline = [[SXHeadLine alloc] initWithFrame:rect];
headline.messageArray = @[@"恭喜 XXX 網(wǎng)上商城隆重上線?。?];
[headline setScrollDuration:0.5 stayDuration:3.0];
[headline changeTapMarqueeAction:^(NSInteger index) {
// 處理點(diǎn)擊事件
}];
[headline start];
[self.view addSubview:headline];
SDCycleScrollView
??最近又發(fā)現(xiàn),無限輪播器的這個(gè)框架也有類似跑馬燈的效果,它是在循環(huán)的時(shí)候不顯示圖片,只循環(huán)顯示文字。使用:
// >>>>>>>>>>>>>>>>>>>>>>>>> demo輪播圖4 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// 網(wǎng)絡(luò)加載 --- 創(chuàng)建只上下滾動(dòng)展示文字的輪播器
// 由于模擬器的渲染問題,如果發(fā)現(xiàn)輪播時(shí)有一條線不必處理,模擬器放大到100%或者真機(jī)調(diào)試是不會(huì)出現(xiàn)那條線的
SDCycleScrollView *cycleScrollView4 = [SDCycleScrollView
cycleScrollViewWithFrame:CGRectMake(0, 750, w, 40)
delegate:self
placeholderImage:nil];
cycleScrollView4.scrollDirection = UICollectionViewScrollDirectionVertical;
cycleScrollView4.onlyDisplayText = YES;
NSMutableArray *titlesArray = [NSMutableArray new];
[titlesArray addObject:@"純文字上下滾動(dòng)輪播"];
[titlesArray addObject:@"純文字上下滾動(dòng)輪播 -- demo輪播圖4"];
[titlesArray addObjectsFromArray:titles];
cycleScrollView4.titlesGroup = [titlesArray copy];
[demoContainerView addSubview:cycleScrollView4];