美文网首页
DYScrollTextView -- 一个高度自定义的文字滚动

DYScrollTextView -- 一个高度自定义的文字滚动

作者: rookiesss | 来源:发表于2019-02-11 17:12 被阅读0次

    源码在这里 ,使用Cocoapod:

    pod 'DYScollTextView'   
    

    简介

    一个高度自定义的文字滚动视图。
    先看效果:

    向上.gif 向下.gif

    功能亮点:
    1.高度自定义cell。
    2.可改变滚动方向。

    用法

    _dataArray = @[@"最长寿男性去世",@"各大卫视春晚阵容",@"陈汉典回应演小品",@"易烊千玺囚服",@"陈昱霖ins",@"个税不填房东信息",@"联合国维和遇袭"];
    _scrollTextView = [[DYScrollTextView alloc] initWithFrame:CGRectMake(0, 100, self.view.bounds.size.width, 90)];
    _scrollTextView.delegate = self;
    _scrollTextView.intervalTime = 3;
    _scrollTextView.scrollPosition = DYScrollPositionTop;
    [self.view addSubview:_scrollTextView];
    _scrollTextView.cellHeight = 30;
    [_scrollTextView start];
    

    核心代码

    - (void)scorll {
        if (_count == 0) return;
        
        if (self.scrollPosition == DYScrollPositionTop) {
            if (self.number == _count * 99) {
                [self initData];
            } else {
                self.number++;
                [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:self.number inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
            }
        } else if (self.scrollPosition == DYScrollPositionBottom) {
            if (self.number == 0) {
                [self initData];
            } else {
                self.number--;
                [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:self.number inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
            }
        }
    }
    

    如果对你有帮助的话,能给 DYScrollTextView 打赏一个小星星吗💕

    相关文章

      网友评论

          本文标题:DYScrollTextView -- 一个高度自定义的文字滚动

          本文链接:https://www.haomeiwen.com/subject/dvwqeqtx.html