ClickOKView.m 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // ClickOKView.m
  3. // smartRhino
  4. //
  5. // Created by tederen on 2019/10/29.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "ClickOKView.h"
  9. #import "DocumentModel.h"
  10. @interface ClickOKView ()
  11. @property (nonatomic, strong) UILabel *zanNameLabel;
  12. @property (nonatomic, strong) UILabel *zanNumLabel;
  13. @end
  14. @implementation ClickOKView
  15. - (instancetype)init{
  16. self = [super init];
  17. if (self) {
  18. [self addSubview:self.zanNameLabel];
  19. [self addSubview:self.zanNumLabel];
  20. [self addSubview:self.zansubBtn];
  21. }
  22. return self;
  23. }
  24. - (void)loadZanListModel:(DocumentModel *)model{
  25. CGFloat topMagin = 14.5f;
  26. _zanNameLabel.text = @"闫丹星、王慧源、张丽";
  27. _zanNameLabel.font = [UIFont systemFontOfSize:16.f];
  28. _zanNameLabel.textColor = [UIColor hexStringToColor:@"636363"];//UIColorHex(636363);
  29. CGSize zanNameSize = [_zanNameLabel sizeThatFits:CGSizeMake(kGXScreenWidth-21*2, MAXFLOAT)];
  30. _zanNameLabel.frame = CGRectMake(21,topMagin,zanNameSize.width, zanNameSize.height);
  31. _zanNumLabel.text = @"等26人点赞";
  32. _zanNumLabel.textColor = UIColorHex(1F87DB);
  33. _zanNumLabel.font = [UIFont systemFontOfSize:16.f];
  34. CGSize zanNumSize = [_zanNumLabel sizeThatFits:CGSizeMake(kGXScreenWidth-21*2, MAXFLOAT)];
  35. _zanNumLabel.frame = CGRectMake(CGRectGetMaxX(_zanNameLabel.frame),topMagin,zanNumSize.width, zanNumSize.height);
  36. _zansubBtn.frame = CGRectMake(kGXScreenWidth -18-21,topMagin,18,14.5);
  37. topMagin += zanNameSize.height;
  38. topMagin += 14.5;
  39. CGRect frame = self.frame;
  40. frame.size.height = topMagin;
  41. self.frame = frame;
  42. }
  43. - (void)loadZanListModel:(NSArray *)zanArr withAllNumber:(NSInteger)total{
  44. CGFloat topMagin = 14.5f;
  45. if (zanArr.count == 0) {
  46. _zanNameLabel.text = @"";
  47. }else if((zanArr.count == 1)){
  48. _zanNameLabel.text = [NSString stringWithFormat:@"%@",zanArr[0][@"UserName"]];
  49. }else if((zanArr.count == 2)){
  50. _zanNameLabel.text = [NSString stringWithFormat:@"%@、%@",zanArr[0][@"UserName"],zanArr[1][@"UserName"]];
  51. }else if((zanArr.count >=3)){
  52. _zanNameLabel.text = [NSString stringWithFormat:@"%@、%@、%@",zanArr[0][@"UserName"],zanArr[1][@"UserName"],zanArr[2][@"UserName"]];
  53. }
  54. _zanNameLabel.font = [UIFont systemFontOfSize:16.f];
  55. _zanNameLabel.textColor = [UIColor hexStringToColor:@"636363"];//UIColorHex(636363);
  56. CGSize zanNameSize = [_zanNameLabel sizeThatFits:CGSizeMake(kGXScreenWidth-21*2, MAXFLOAT)];
  57. _zanNameLabel.frame = CGRectMake(21,topMagin,zanNameSize.width, zanNameSize.height);
  58. _zanNumLabel.text = [NSString stringWithFormat:@"等%ld人点赞",(long)total];
  59. if (zanArr.count == 0) {
  60. _zanNumLabel.text = @"";
  61. }
  62. _zanNumLabel.textColor = UIColorHex(1F87DB);
  63. _zanNumLabel.font = [UIFont systemFontOfSize:16.f];
  64. CGSize zanNumSize = [_zanNumLabel sizeThatFits:CGSizeMake(kGXScreenWidth-21*2, MAXFLOAT)];
  65. _zanNumLabel.frame = CGRectMake(CGRectGetMaxX(_zanNameLabel.frame),topMagin,zanNumSize.width, zanNumSize.height);
  66. _zansubBtn.frame = CGRectMake(kGXScreenWidth -18-21,topMagin,18,14.5);
  67. topMagin += zanNameSize.height;
  68. topMagin += 14.5;
  69. CGRect frame = self.frame;
  70. frame.size.height = topMagin;
  71. self.frame = frame;
  72. }
  73. - (void)gotoZanList:(UIButton *)sender {
  74. if (self.buttonBlock) {
  75. self.buttonBlock();
  76. }
  77. if ([self respondsToSelector:@selector(didClickOKViewDelegate)]) {
  78. [self.delegate didClickOKViewDelegate];
  79. }
  80. }
  81. #pragma mark - setter
  82. - (UILabel *)zanNameLabel{
  83. if(!_zanNameLabel){
  84. _zanNameLabel = [UILabel new];
  85. _zanNameLabel.numberOfLines = 0;
  86. }
  87. return _zanNameLabel;
  88. }
  89. - (UILabel *)zanNumLabel{
  90. if(!_zanNumLabel){
  91. _zanNumLabel = [UILabel new];
  92. _zanNumLabel.numberOfLines = 0;
  93. }
  94. return _zanNumLabel;
  95. }
  96. - (TDButton *)zansubBtn{
  97. if (!_zansubBtn) {
  98. _zansubBtn = [TDButton buttonWithType:UIButtonTypeCustom];
  99. [_zansubBtn setImage:IMG(@"icon_xq_zanBtn") forState:UIControlStateNormal];
  100. [_zansubBtn addTarget:self action:@selector(gotoZanList:) forControlEvents:UIControlEventTouchDown];
  101. [_zansubBtn setCurrentButtonHotSize:CGSizeZero];
  102. }
  103. return _zansubBtn;
  104. }
  105. @end