- GitHub源碼:TXScrollLabelView
- star: 400+
??????
以下內容來源于官方源碼、 README 文檔、測試 Demo或個人使用總結 !
用法
/** Step1: 滾動文字 */
NSString *scrollTitle = @"xxxxxx";
/** Step2: 創建 ScrollLabelView */
TXScrollLabelView *scrollLabelView = [TXScrollLabelView scrollWithTitle:scrollTitle type:TXScrollLabelViewTypeFlipNoRepeat velocity:velocity options:UIViewAnimationOptionCurveEaseInOut];
/** Step3: 設置代理進行回調(Optional) */
scrollLabelView.scrollLabelViewDelegate = self;
/** Step4: 布局(Required) */
scrollLabelView.frame = CGRectMake(50, 100, 300, 30);
[self.view addSubview:scrollLabelView];
/** Step5: 開始滾動(Start scrolling!) */
[scrollLabelView beginScrolling];
Demo:
// 滾動Label
// step1:獲取滾動內容
NSString *scrollTitle = @"恭喜 XXX 網上商城隆重上線!";
// step2:創建scrollLabelView對象
TXScrollLabelView *scrollLabelView = [TXScrollLabelView scrollWithTitle:scrollTitle type:TXScrollLabelViewTypeFlipRepeat velocity:3 options:UIViewAnimationOptionTransitionNone];
scrollLabelView.backgroundColor = [UIColor clearColor];
scrollLabelView.scrollTitleColor = [UIColor blackColor];
// step3:設置代理進行回調(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:開始滾動
[scrollLabelView beginScrolling];
其他
Wonderful
這個框架里也有跑馬燈的兩個類,提取出來使用對于整個APP來說相比于這個框架更輕量簡介些。使用:
CGRect rect = CGRectMake(31,31, 240, 21);
SXHeadLine *headline = [[SXHeadLine alloc] initWithFrame:rect];
headline.messageArray = @[@"恭喜 XXX 網上商城隆重上線!!"];
[headline setScrollDuration:0.5 stayDuration:3.0];
[headline changeTapMarqueeAction:^(NSInteger index) {
// 處理點擊事件
}];
[headline start];
[self.view addSubview:headline];
SDCycleScrollView
??最近又發現,無限輪播器的這個框架也有類似跑馬燈的效果,它是在循環的時候不顯示圖片,只循環顯示文字。使用:
// >>>>>>>>>>>>>>>>>>>>>>>>> demo輪播圖4 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// 網絡加載 --- 創建只上下滾動展示文字的輪播器
// 由于模擬器的渲染問題,如果發現輪播時有一條線不必處理,模擬器放大到100%或者真機調試是不會出現那條線的
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:@"純文字上下滾動輪播"];
[titlesArray addObject:@"純文字上下滾動輪播 -- demo輪播圖4"];
[titlesArray addObjectsFromArray:titles];
cycleScrollView4.titlesGroup = [titlesArray copy];
[demoContainerView addSubview:cycleScrollView4];