65 lines
1.8 KiB
Mathematica
65 lines
1.8 KiB
Mathematica
|
|
//
|
||
|
|
// QXBadgeButton.m
|
||
|
|
// QXLive
|
||
|
|
//
|
||
|
|
// Created by 启星 on 2025/7/28.
|
||
|
|
//
|
||
|
|
|
||
|
|
#import "QXBadgeButton.h"
|
||
|
|
|
||
|
|
@implementation QXBadgeButton
|
||
|
|
- (instancetype)init
|
||
|
|
{
|
||
|
|
self = [super init];
|
||
|
|
if (self) {
|
||
|
|
[self addSubview:self.unreadView];
|
||
|
|
[self.unreadView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.top.mas_equalTo(self);
|
||
|
|
make.right.equalTo(self);
|
||
|
|
make.width.mas_equalTo(kScale375(17));
|
||
|
|
make.height.mas_equalTo(kScale375(17));
|
||
|
|
}];
|
||
|
|
|
||
|
|
|
||
|
|
[self.unreadView.unReadLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.center.mas_equalTo(self.unreadView);
|
||
|
|
make.size.mas_equalTo(self.unreadView.unReadLabel);
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
return self;
|
||
|
|
}
|
||
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
||
|
|
{
|
||
|
|
self = [super initWithFrame:frame];
|
||
|
|
if (self) {
|
||
|
|
[self addSubview:self.unreadView];
|
||
|
|
[self.unreadView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.top.mas_equalTo(self);
|
||
|
|
make.right.equalTo(self);
|
||
|
|
make.width.mas_equalTo(kScale375(17));
|
||
|
|
make.height.mas_equalTo(kScale375(17));
|
||
|
|
}];
|
||
|
|
|
||
|
|
|
||
|
|
[self.unreadView.unReadLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.center.mas_equalTo(self.unreadView);
|
||
|
|
make.size.mas_equalTo(self.unreadView.unReadLabel);
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
return self;
|
||
|
|
}
|
||
|
|
-(TUIUnReadView *)unreadView{
|
||
|
|
if (!_unreadView) {
|
||
|
|
_unreadView = [[TUIUnReadView alloc] init];
|
||
|
|
_unreadView.userInteractionEnabled = NO;
|
||
|
|
[_unreadView setNum:0];
|
||
|
|
|
||
|
|
[_unreadView.unReadLabel sizeToFit];
|
||
|
|
|
||
|
|
_unreadView.layer.cornerRadius = kScale375(10);
|
||
|
|
[_unreadView.layer masksToBounds];
|
||
|
|
}
|
||
|
|
return _unreadView;
|
||
|
|
}
|
||
|
|
@end
|