SeatTipsView.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // SeatTipsView.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by 王智 on 2022/4/1.
  6. //
  7. #import "SeatTipsView.h"
  8. @interface SeatTipsView ()
  9. @property (nonatomic, strong) UILabel *countLabel;
  10. @end
  11. @implementation SeatTipsView
  12. - (instancetype)init {
  13. self = [super init];
  14. if (self) {
  15. self.backgroundColor = HexRGB(0xff4e19);
  16. self.layer.borderWidth = 1.0f;
  17. self.layer.borderColor = HexRGB(0xffffff).CGColor;
  18. [self setupRadius];
  19. [self addSubview:self.countLabel];
  20. [self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  21. make.left.mas_equalTo(self.mas_left).offset(6);
  22. make.top.mas_equalTo(self.mas_top).offset(2);
  23. make.right.mas_equalTo(self.mas_right).offset(-7);
  24. make.bottom.mas_equalTo(self.mas_bottom).offset(-2);
  25. }];
  26. [self hideView];
  27. }
  28. return self;
  29. }
  30. - (void)setupRadius {
  31. if (@available(iOS 11.0, *)) {
  32. self.layer.cornerRadius = 8;
  33. self.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner | kCALayerMaxXMaxYCorner;
  34. }
  35. else {
  36. UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight | UIRectCornerBottomRight cornerRadii:CGSizeMake(8, 8)];
  37. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  38. maskLayer.frame = self.bounds;
  39. maskLayer.path = path.CGPath;
  40. self.layer.mask = maskLayer;
  41. }
  42. self.layer.masksToBounds = YES;
  43. }
  44. - (void)configCountMessage:(NSString *)countString {
  45. self.countLabel.text = countString;
  46. }
  47. - (void)showTipsView {
  48. self.hidden = NO;
  49. }
  50. - (void)hideView {
  51. self.hidden = YES;
  52. }
  53. - (UILabel *)countLabel {
  54. if (!_countLabel) {
  55. _countLabel = [[UILabel alloc] init];
  56. _countLabel.textColor = HexRGB(0xffffff);
  57. _countLabel.font = [UIFont systemFontOfSize:11.0f weight:UIFontWeightMedium];
  58. }
  59. return _countLabel;
  60. }
  61. /*
  62. // Only override drawRect: if you perform custom drawing.
  63. // An empty implementation adversely affects performance during animation.
  64. - (void)drawRect:(CGRect)rect {
  65. // Drawing code
  66. }
  67. */
  68. @end