YXMenuItemView.m 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // YXMenuItemView.m
  3. // Temperature
  4. //
  5. // Created by z on 2025/1/16.
  6. //
  7. #import "YXMenuItemView.h"
  8. @implementation YXMenuItemView
  9. - (instancetype)init
  10. {
  11. self = [super init];
  12. if (self) {
  13. [self setItemSubViews];
  14. }
  15. return self;
  16. }
  17. -(void)setItemSubViews
  18. {
  19. UILabel *textLabel = [[UILabel alloc]init];
  20. textLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
  21. textLabel.textAlignment = NSTextAlignmentCenter;
  22. textLabel.textColor = [UIColor colorWithHexString:@"#333333"];
  23. [self addSubview:textLabel];
  24. [textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  25. make.top.equalTo(@0);
  26. make.left.equalTo(@0);
  27. make.right.equalTo(@0);
  28. make.bottom.equalTo(@0);
  29. }];
  30. self.textLabel = textLabel;
  31. UIView *colorView = [[UIView alloc]init];
  32. colorView.backgroundColor = [UIColor colorWithHexString:@"#267AFF" alpha:0.2];
  33. [self addSubview:colorView];
  34. [colorView mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.height.equalTo(@6);
  36. make.width.equalTo(@60);
  37. make.centerX.equalTo(@0);
  38. make.centerY.equalTo(@6);
  39. }];
  40. colorView.hidden = YES;
  41. self.colorView = colorView;
  42. }
  43. /*
  44. // Only override drawRect: if you perform custom drawing.
  45. // An empty implementation adversely affects performance during animation.
  46. - (void)drawRect:(CGRect)rect {
  47. // Drawing code
  48. }
  49. */
  50. @end