猎豆优选

LDTodayNewsView.m 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // LDTodayNewsView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/12/10.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDTodayNewsView.h"
  9. #import "DCTitleRolling.h"
  10. #import "LDScrollNewsModel.h"
  11. @interface LDTodayNewsView ()<CDDRollingDelegate>
  12. {
  13. UIView *_bgView;
  14. }
  15. @property (nonatomic, strong) DCTitleRolling *scrollLabel;
  16. @end
  17. @implementation LDTodayNewsView
  18. - (instancetype)initWithFrame:(CGRect)frame
  19. {
  20. self = [super initWithFrame:frame];
  21. if (self) {
  22. [self initSubViews];
  23. }
  24. return self;
  25. }
  26. - (void)initSubViews {
  27. UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(5, 5, SCREEN_WIDTH-10, 37)];
  28. bgView.backgroundColor = [UIColor YHColorWithHex:0xFDF8F1];
  29. bgView.layer.cornerRadius = 6;
  30. bgView.layer.masksToBounds = YES;
  31. [self addSubview:bgView];
  32. _bgView = bgView;
  33. UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  34. rightBtn.frame = CGRectMake(bgView.width-20, 0, 20, bgView.height);
  35. [rightBtn setImage:[UIImage imageNamed:@"xiayibu"] forState:UIControlStateNormal];
  36. [bgView addSubview:rightBtn];
  37. [rightBtn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
  38. }
  39. - (void)btnClick {
  40. if (self.clickMessage) {
  41. self.clickMessage(0);
  42. }
  43. }
  44. - (void)setDataList:(NSArray *)list {
  45. [self.scrollLabel removeFromSuperview];
  46. NSMutableArray *titleArr = [NSMutableArray array];
  47. NSMutableArray *rightImgs = [NSMutableArray array];
  48. for (LDScrollNewsModel *model in list) {
  49. [titleArr addObject:model.title];
  50. [rightImgs addObject:@"goods"];
  51. }
  52. 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) {
  53. *rollingTime = 1;
  54. *rightImages = rightImgs;
  55. *rolTitles = titleArr;
  56. *leftImage = @"toutiaol";
  57. *interval = 5.0;
  58. *titleFont = 13;
  59. *titleColor = [UIColor YHColorWithHex:0x262626];
  60. }];
  61. [self.scrollLabel dc_beginRolling];
  62. self.scrollLabel.backgroundColor = [UIColor clearColor];
  63. self.scrollLabel.delegate = self;
  64. [_bgView addSubview:self.scrollLabel];
  65. }
  66. #pragma mark - <CDDRollingDelegate>
  67. - (void)dc_RollingViewSelectWithActionAtIndex:(NSInteger)index
  68. {
  69. if (self.clickMessage) {
  70. self.clickMessage(index);
  71. }
  72. }
  73. @end