1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- //
- // LDTodayNewsView.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/12/10.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "LDTodayNewsView.h"
- #import "DCTitleRolling.h"
- #import "LDScrollNewsModel.h"
- @interface LDTodayNewsView ()<CDDRollingDelegate>
- {
- UIView *_bgView;
- }
- @property (nonatomic, strong) DCTitleRolling *scrollLabel;
- @end
- @implementation LDTodayNewsView
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
- [self initSubViews];
- }
- return self;
- }
- - (void)initSubViews {
- UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(5, 5, SCREEN_WIDTH-10, 37)];
- bgView.backgroundColor = [UIColor YHColorWithHex:0xFDF8F1];
- bgView.layer.cornerRadius = 6;
- bgView.layer.masksToBounds = YES;
- [self addSubview:bgView];
- _bgView = bgView;
-
- UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- rightBtn.frame = CGRectMake(bgView.width-20, 0, 20, bgView.height);
- [rightBtn setImage:[UIImage imageNamed:@"xiayibu"] forState:UIControlStateNormal];
- [bgView addSubview:rightBtn];
- [rightBtn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
-
- }
- - (void)btnClick {
- if (self.clickMessage) {
- self.clickMessage(0);
- }
- }
- - (void)setDataList:(NSArray *)list {
-
- [self.scrollLabel removeFromSuperview];
- NSMutableArray *titleArr = [NSMutableArray array];
- NSMutableArray *rightImgs = [NSMutableArray array];
- for (LDScrollNewsModel *model in list) {
- [titleArr addObject:model.title];
- [rightImgs addObject:@"goods"];
- }
-
- self.scrollLabel = [[DCTitleRolling alloc] initWithFrame:CGRectMake(5, 0, _bgView.width -40, _bgView.height) WithTitleData:^(CDDRollingGroupStyle *rollingGroupStyle, NSString *__autoreleasing *leftImage, NSArray *__autoreleasing *rolTitles, NSArray *__autoreleasing *rolTags, NSArray *__autoreleasing *rightImages, NSString *__autoreleasing *rightbuttonTitle, NSInteger *interval, float *rollingTime, NSInteger *titleFont, UIColor *__autoreleasing *titleColor, BOOL *isShowTagBorder) {
-
- *rollingTime = 1;
- *rightImages = rightImgs;
- *rolTitles = titleArr;
- *leftImage = @"toutiaol";
- *interval = 5.0;
- *titleFont = 13;
- *titleColor = [UIColor YHColorWithHex:0x262626];
- }];
- [self.scrollLabel dc_beginRolling];
- self.scrollLabel.backgroundColor = [UIColor clearColor];
- self.scrollLabel.delegate = self;
-
- [_bgView addSubview:self.scrollLabel];
- }
- #pragma mark - <CDDRollingDelegate>
- - (void)dc_RollingViewSelectWithActionAtIndex:(NSInteger)index
- {
- if (self.clickMessage) {
- self.clickMessage(index);
- }
- }
- @end
|