BogoNewsHeadView.m 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // BogoNewsHeadView.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2021/4/13.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "BogoNewsHeadView.h"
  9. @implementation BogoNewsHeadView
  10. - (instancetype)initWithFrame:(CGRect)frame
  11. {
  12. self = [super initWithFrame:frame];
  13. if (self) {
  14. [self setUpView];
  15. UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, self.height - kRealValue(4), kScreenW, kRealValue(kRealValue(4)))];
  16. line.backgroundColor = kClearColor;
  17. [self addSubview:line];
  18. }
  19. return self;
  20. }
  21. -(void)clickBtn:(UIButton *)sender{
  22. if (self.delegate && [self.delegate respondsToSelector:@selector(clickHeadControl:)]) {
  23. [self.delegate clickHeadControl:sender.tag - 100];
  24. }
  25. }
  26. - (void)setModel:(BogoNewsTabNumModel *)model{
  27. QMUIButton *likeBtn = [self viewWithTag:100];
  28. QMUIButton *replyBtn = [self viewWithTag:100 + 1];
  29. likeBtn.shouldHideBadgeAtZero = YES;
  30. likeBtn.badgeValue = [NSString stringWithFormat:@"%ld",model.bzone_like];
  31. likeBtn.badgeOriginX = likeBtn.width / 2 + 10;
  32. likeBtn.badgeOriginY = likeBtn.top + 10;
  33. replyBtn.shouldHideBadgeAtZero = YES;
  34. replyBtn.badgeValue = [NSString stringWithFormat:@"%ld",model.bzone_reply];
  35. replyBtn.badgeOriginX = replyBtn.width / 2 + 10;
  36. replyBtn.badgeOriginY = replyBtn.top + 10;
  37. }
  38. -(void)setUpView{
  39. NSArray *listArr = @[ASLocalizedString(@"点赞"),ASLocalizedString(@"评论"),ASLocalizedString(@"粉丝"),ASLocalizedString(@"关注")];
  40. NSArray *imgArr = @[@"bogo_news_top_likes",@"bogo_news_top_comment",@"bogo_news_top_fans",@"bogo_news_top_concert"];
  41. CGFloat viewWidth = kScreenW / 4;
  42. for (int i = 0; i < 4; i ++) {
  43. QMUIButton *btn = [QMUIButton buttonWithType:UIButtonTypeCustom];
  44. btn.frame = CGRectMake(viewWidth * i, 0, viewWidth, viewWidth);
  45. [btn setTitleColor:[UIColor colorWithHexString:@"#333333"] forState:UIControlStateNormal];
  46. [btn setImage:[UIImage imageNamed:imgArr[i]] forState:UIControlStateNormal];
  47. [btn setTitle:listArr[i] forState:UIControlStateNormal];
  48. btn.tag = 100 + i;
  49. btn.titleLabel.font = [UIFont systemFontOfSize:16];
  50. btn.imagePosition = QMUIButtonImagePositionTop;
  51. btn.spacingBetweenImageAndTitle = 5;
  52. [btn addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
  53. // btn.backgroundColor = ;
  54. [self addSubview:btn];
  55. }
  56. }
  57. @end