KWHisCollectHeaderView.m 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // KWHisCollectHeaderView.m
  3. // westkissMob
  4. //
  5. // Created by iOS on 2022/9/14.
  6. //
  7. #import "KWHisCollectHeaderView.h"
  8. @interface KWHisCollectHeaderView ()
  9. @end
  10. @implementation KWHisCollectHeaderView
  11. - (instancetype)initWithFrame:(CGRect)frame {
  12. self = [super initWithFrame:frame];
  13. if (self) {
  14. [self configSubV];
  15. }
  16. return self;
  17. }
  18. - (void)configSubV {
  19. self.backgroundColor = [UIColor colorWithHexString:@"#f8f8f8"];
  20. [self addSubview:self.titleLb];
  21. [self addSubview:self.imgV];
  22. [self addSubview:self.btn];
  23. [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  24. make.top.equalTo(self).offset(13);
  25. make.left.equalTo(self).offset(20);
  26. make.bottom.equalTo(self).offset(-7);
  27. make.height.equalTo(@20);
  28. }];
  29. [self.imgV mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.left.equalTo(self.titleLb.mas_right).offset(10);
  31. make.bottom.equalTo(self).offset(-10);
  32. make.right.equalTo(self).offset(-20);
  33. make.width.equalTo(@24);
  34. make.height.equalTo(@24);
  35. }];
  36. [self.btn mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.edges.equalTo(self.imgV);
  38. }];
  39. }
  40. - (void)awakeFromNib {
  41. [super awakeFromNib];
  42. // Initialization code
  43. }
  44. - (UILabel *)titleLb {
  45. if (!_titleLb) {
  46. UILabel *lb = [[UILabel alloc] init];
  47. lb.font = [UIFont fontWithName:Rob_Bold size:14];
  48. lb.textColor = [UIColor colorWithHexString:@"#0b0b0b"];
  49. lb.textAlignment = NSTextAlignmentLeft;
  50. lb.backgroundColor = [UIColor clearColor];
  51. lb.numberOfLines = 1;
  52. _titleLb = lb;
  53. }
  54. return _titleLb;
  55. }
  56. -(UIImageView *)imgV {
  57. if (!_imgV) {
  58. UIImageView *img = [[UIImageView alloc] init];
  59. img.contentMode = UIViewContentModeScaleAspectFit;
  60. img.image = [UIImage imageNamed:@"search_his_clean"];
  61. _imgV = img;
  62. }
  63. return _imgV;
  64. }
  65. -(UIButton *)btn {
  66. if (!_btn) {
  67. UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
  68. [bt addTarget:self action:@selector(clickAction) forControlEvents:UIControlEventTouchUpInside];
  69. bt.backgroundColor = UIColor.clearColor;
  70. [bt setTitle:@"" forState:UIControlStateNormal];
  71. _btn = bt;
  72. }
  73. return _btn;
  74. }
  75. - (void)clickAction {
  76. if (self.callBack) {
  77. self.callBack();
  78. }
  79. }
  80. @end