1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- //
- // SeatTipsView.m
- // KulexiuForTeacher
- //
- // Created by 王智 on 2022/4/1.
- //
- #import "SeatTipsView.h"
- @interface SeatTipsView ()
- @property (nonatomic, strong) UILabel *countLabel;
- @end
- @implementation SeatTipsView
- - (instancetype)init {
- self = [super init];
- if (self) {
- self.backgroundColor = HexRGB(0xff4e19);
- self.layer.borderWidth = 1.0f;
- self.layer.borderColor = HexRGB(0xffffff).CGColor;
- [self setupRadius];
- [self addSubview:self.countLabel];
- [self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.mas_left).offset(6);
- make.top.mas_equalTo(self.mas_top).offset(2);
- make.right.mas_equalTo(self.mas_right).offset(-7);
- make.bottom.mas_equalTo(self.mas_bottom).offset(-2);
- }];
- [self hideView];
- }
- return self;
- }
- - (void)setupRadius {
- if (@available(iOS 11.0, *)) {
- self.layer.cornerRadius = 8;
- self.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner | kCALayerMaxXMaxYCorner;
- }
- else {
- UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight | UIRectCornerBottomRight cornerRadii:CGSizeMake(8, 8)];
- CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
- maskLayer.frame = self.bounds;
- maskLayer.path = path.CGPath;
- self.layer.mask = maskLayer;
- }
- self.layer.masksToBounds = YES;
- }
- - (void)configCountMessage:(NSString *)countString {
- self.countLabel.text = countString;
- }
- - (void)showTipsView {
- self.hidden = NO;
- }
- - (void)hideView {
- self.hidden = YES;
- }
- - (UILabel *)countLabel {
- if (!_countLabel) {
- _countLabel = [[UILabel alloc] init];
- _countLabel.textColor = HexRGB(0xffffff);
- _countLabel.font = [UIFont systemFontOfSize:11.0f weight:UIFontWeightMedium];
- }
- return _countLabel;
- }
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- @end
|