《省钱达人》与《猎豆优选》UI相同版。域名tbk

DRAchievementView.m 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // DRAchievementView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/8/2.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRAchievementView.h"
  9. @interface DRAchievementView (){
  10. NSArray *_buttons;
  11. NSString *_title;
  12. }
  13. @end
  14. @implementation DRAchievementView
  15. - (instancetype)initWithFrame:(CGRect)frame titleInfoArray:(NSArray *)array title:(NSString *)title{
  16. self = [super initWithFrame:frame];
  17. if (self) {
  18. _title = title;
  19. _buttons = array;
  20. self.backgroundColor = [UIColor whiteColor];
  21. self.layer.cornerRadius = 6;
  22. [self initSubViews];
  23. // self.layer.shadowColor = [UIColor homeRedColor].CGColor;
  24. // self.layer.shadowOffset = CGSizeMake(0, 0);
  25. // self.layer.shadowOpacity = 0.3;
  26. // self.layer.shadowRadius = 3;
  27. }
  28. return self;
  29. }
  30. - (void)initSubViews {
  31. UILabel *titleLb = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, 200, Fitsize(36))];
  32. titleLb.font = [UIFont systemFontOfSize:Fitsize(14)];
  33. titleLb.textColor = [UIColor YHColorWithHex:0x000000];
  34. titleLb.text = _title;
  35. [self addSubview:titleLb];
  36. UILabel *Line = [[UILabel alloc] initWithFrame:CGRectMake(5, titleLb.bottom, self.width-10, 1)];
  37. Line.backgroundColor = [UIColor yhGrayColor];
  38. [self addSubview:Line];
  39. CGFloat width = self.width/4;
  40. CGFloat height = Fitsize(20);
  41. for (int i = 0; i < _buttons.count; i++) {
  42. UIView *bg = [[UIView alloc] initWithFrame:CGRectMake(width * (i%4), Line.bottom+(i/4)*height, width, width)];
  43. bg.tag = 1000+i;
  44. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapViewAction:)];
  45. [bg addGestureRecognizer:tap];
  46. [self addSubview:bg];
  47. UILabel *detailLb = [[UILabel alloc] initWithFrame:CGRectMake(width * (i%4),Line.bottom+Fitsize(20)+ (i/4)*height, width, height)];
  48. detailLb.text = @"--";
  49. detailLb.font = [UIFont boldSystemFontOfSize:Fitsize(16)];
  50. detailLb.textAlignment = NSTextAlignmentCenter;
  51. detailLb.textColor = [UIColor homeRedColor];
  52. detailLb.tag = 10000 + i;
  53. [self addSubview:detailLb];
  54. UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(width * (i%4),detailLb.bottom+Fitsize(10), width, height)];
  55. title.text = _buttons[i];
  56. title.textColor = [UIColor YHColorWithHex:0x7c7c7c];
  57. title.font = [UIFont systemFontOfSize:Fitsize(12)];
  58. title.textAlignment = NSTextAlignmentCenter;
  59. [self addSubview:title];
  60. }
  61. NSInteger row = _buttons.count/4;
  62. if (_buttons.count%4 != 0) {
  63. row += 1;
  64. }
  65. self.height = Line.bottom + row * width;
  66. }
  67. - (void)tapViewAction:(UITapGestureRecognizer *)tap {
  68. NSInteger index = tap.view.tag - 1000;
  69. if (self.tapMenuBlock) {
  70. self.tapMenuBlock(index);
  71. }
  72. }
  73. - (void)setUserInfo:(DRUserInfo *)userInfo {
  74. if (userInfo) {
  75. NSString *this_day_order_count = userInfo.this_day_order_count==nil?@"--":userInfo.this_day_order_count;
  76. NSString *this_day_forecast_income = userInfo.this_day_order_count==nil?@"--":userInfo.this_day_forecast_income;
  77. NSString *register_friends = userInfo.this_day_order_count==nil?@"--":userInfo.register_friends;
  78. NSString *no_register_friends = userInfo.this_day_order_count==nil?@"--":userInfo.no_register_friends;
  79. NSArray *infoArr = @[this_day_order_count,
  80. this_day_forecast_income,
  81. register_friends,
  82. no_register_friends];
  83. for (int i = 0; i < infoArr.count; i++) {
  84. UILabel *detailLb = [self viewWithTag:10000+i];
  85. detailLb.text = infoArr[i];
  86. }
  87. }
  88. }
  89. @end