中奖轮播公告 文字轮播

中奖轮播公告,在SDCycleScrollView的基础上增加了一个属性来设置是否允许文字超出宽度后向右滚动,超出UIlabel的进行滚动展示,其他的正常静态展示,下载DEMO

test.gif

1:富文本+超出固定宽度滚动 参数请到SDCollectionViewCell里面改(固定宽度 ,滚动间隔 ,延迟时间)

    SDCycleScrollView *cycleScrollView1 = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 80, w, 20) delegate:self placeholderImage:nil];
    cycleScrollView1.backgroundColor = [UIColor whiteColor];
    cycleScrollView1.scrollDirection = UICollectionViewScrollDirectionVertical;
    cycleScrollView1.onlyDisplayText = YES;
    cycleScrollView1.textScrollEnable = YES;
    cycleScrollView1.titleLabelTextColor = [UIColor blackColor];
    
    NSMutableArray *attributeTitleArray = [NSMutableArray new];
    for (int i = 0; i < titleArr.count; i++) {
        NSString *titleStr = titleArr[i];
        NSMutableAttributedString *attr = [[NSMutableAttributedString alloc]initWithString:titleStr];
        [attr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(2, 3)];
        [attributeTitleArray addObject:attr];
    }
    cycleScrollView1.displayType = SDDisplayTypeAttributeText;
    cycleScrollView1.titlesGroup = [attributeTitleArray copy];
    
    [self.view addSubview:cycleScrollView1];

2:正常文字+超出固定宽度滚动

    SDCycleScrollView *cycleScrollView2 = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 120, w, 20) delegate:self placeholderImage:nil];
    cycleScrollView2.backgroundColor = [UIColor whiteColor];
    cycleScrollView2.scrollDirection = UICollectionViewScrollDirectionVertical;
    cycleScrollView2.onlyDisplayText = YES;
    cycleScrollView2.textScrollEnable = YES;
    cycleScrollView2.titleLabelTextColor = [UIColor blackColor];
    cycleScrollView2.displayType = SDDisplayTypeNormalText;
    cycleScrollView2.titlesGroup = titleArr;
    [self.view addSubview:cycleScrollView2];

3:正常文字+不滚动

    SDCycleScrollView *cycleScrollView4 = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 160, w, 20) delegate:self placeholderImage:nil];
    cycleScrollView4.backgroundColor = [UIColor whiteColor];
    cycleScrollView4.scrollDirection = UICollectionViewScrollDirectionVertical;
    cycleScrollView4.onlyDisplayText = YES;
    //设置是否滚动
    cycleScrollView4.textScrollEnable = NO;
    cycleScrollView4.titleLabelTextColor = [UIColor blackColor];
    cycleScrollView4.displayType = SDDisplayTypeNormalText;
    cycleScrollView4.titlesGroup = titleArr;
    [self.view addSubview:cycleScrollView4];

你可能感兴趣的:(中奖轮播公告 文字轮播)