猎豆优选

LDAchievementDetailView.m 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //
  2. // LDAchievementDetailView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/8/2.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDAchievementDetailView.h"
  9. @interface LDAchievementDetailView () {
  10. NSArray *_titles;
  11. }
  12. @end
  13. @implementation LDAchievementDetailView
  14. - (instancetype)initWithFrame:(CGRect)frame titles:(NSArray *)titles{
  15. self = [super initWithFrame:frame];
  16. if (self) {
  17. _titles = titles;
  18. [self initSubViews];
  19. }
  20. return self;
  21. }
  22. - (void)initSubViews {
  23. CGFloat width = self.width/4;
  24. CGFloat height = Fitsize(20);
  25. self.height = width + Fitsize(10);
  26. for (int i = 0; i < _titles.count; i++) {
  27. UIView *bg = [[UIView alloc] initWithFrame:CGRectMake(self.width/2 * i, 0, self.width/2, self.height)];
  28. [self addSubview:bg];
  29. UIView *alphaView = [[UIView alloc] initWithFrame:bg.bounds];
  30. alphaView.backgroundColor = [UIColor clearColor];
  31. alphaView.tag = 1000+i;
  32. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapViewAction:)];
  33. [alphaView addGestureRecognizer:tap];
  34. [bg addSubview:alphaView];
  35. UILabel *topTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, bg.width, FITSIZE(40))];
  36. topTitle.textAlignment = NSTextAlignmentCenter;
  37. topTitle.font = [UIFont systemFontOfSize:Fitsize(14)];
  38. topTitle.textColor = [UIColor YHColorWithHex:0x333333];
  39. topTitle.text = _titles[i];
  40. [bg addSubview:topTitle];
  41. NSArray *subTitles = @[@"订单",@"佣金"];
  42. for (int j = 0; j < subTitles.count; j++) {
  43. UILabel *detailLb = [[UILabel alloc] initWithFrame:CGRectMake(self.width/4 * (j%4),topTitle.bottom + (j/4)*height, width, height)];
  44. detailLb.text = @"--";
  45. detailLb.font = [UIFont boldSystemFontOfSize:Fitsize(16)];
  46. detailLb.textAlignment = NSTextAlignmentCenter;
  47. detailLb.textColor = [UIColor homeRedColor];
  48. detailLb.tag = (i+1)*2000+j;
  49. [bg addSubview:detailLb];
  50. UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(width * (j%4),detailLb.bottom+Fitsize(10), width, height)];
  51. title.text = subTitles[j];
  52. title.textColor = [UIColor YHColorWithHex:0x7c7c7c];
  53. title.font = [UIFont systemFontOfSize:Fitsize(12)];
  54. title.textAlignment = NSTextAlignmentCenter;
  55. [bg addSubview:title];
  56. }
  57. }
  58. UILabel *line = [[UILabel alloc] initWithFrame:CGRectMake(self.width/2, 0, 1, Fitsize(80))];
  59. line.backgroundColor = [UIColor yhGrayColor];
  60. line.centerY = self.height/2;
  61. [self addSubview:line];
  62. }
  63. - (void)setAccountInfo:(NSArray *)infoArr {
  64. for (int i = 0; i < infoArr.count; i++) {
  65. NSArray *arr = infoArr[i];
  66. for (int j = 0; j < arr.count; j++) {
  67. UILabel *label = [self viewWithTag:(i+1)*2000+j];
  68. label.text = arr[j];
  69. }
  70. }
  71. }
  72. - (void)tapViewAction:(UITapGestureRecognizer *)tap {
  73. NSInteger index = tap.view.tag - 1000;
  74. if (self.tapIncomeBlock) {
  75. self.tapIncomeBlock(index);
  76. }
  77. }
  78. @end