YXItemView.m 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // YXItemView.m
  3. // Temperature
  4. //
  5. // Created by z on 2025/1/15.
  6. //
  7. #import "YXItemView.h"
  8. @implementation YXItemView
  9. - (instancetype)init
  10. {
  11. self = [super init];
  12. if (self) {
  13. self.backgroundColor = UIColor.whiteColor;
  14. [self setItemSubViews];
  15. }
  16. return self;
  17. }
  18. -(void)setItemSubViews
  19. {
  20. UIImageView *picView = [[UIImageView alloc]init];
  21. [self addSubview:picView];
  22. [picView mas_makeConstraints:^(MASConstraintMaker *make) {
  23. make.centerY.equalTo(self.mas_centerY);
  24. make.left.equalTo(@10);
  25. make.width.equalTo(@20);
  26. make.height.equalTo(@20);
  27. }];
  28. self.picImgView = picView;
  29. UIView *colorView = [[UIView alloc]init];
  30. colorView.backgroundColor = [UIColor colorWithHexString:@"#48E441"];
  31. [self addSubview:colorView];
  32. [colorView mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.centerY.equalTo(self.mas_centerY);
  34. make.right.equalTo(@-10);
  35. make.width.equalTo(@6);
  36. make.height.equalTo(@6);
  37. }];
  38. self.colorView = colorView;
  39. colorView.layer.cornerRadius = 3;
  40. UILabel *textLabel = [[UILabel alloc]init];
  41. textLabel.font = [UIFont systemFontOfSize:14];
  42. textLabel.textAlignment = NSTextAlignmentCenter;
  43. textLabel.textColor = [UIColor colorWithHexString:@"#333333"];
  44. [self addSubview:textLabel];
  45. [textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.centerY.equalTo(self.mas_centerY);
  47. make.left.equalTo(picView.mas_right).offset(5);
  48. make.right.equalTo(colorView.mas_right).offset(-5);
  49. make.height.equalTo(@30);
  50. }];
  51. self.textLabel = textLabel;
  52. }
  53. /*
  54. // Only override drawRect: if you perform custom drawing.
  55. // An empty implementation adversely affects performance during animation.
  56. - (void)drawRect:(CGRect)rect {
  57. // Drawing code
  58. }
  59. */
  60. @end