You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

121 lines
3.7 KiB

//
// TabMessageTableViewCell.m
// LekangGuard
//
// Created by ecell on 2023/6/7.
//
#import "TabMessageTableViewCell.h"
@interface TabMessageTableViewCell ()
/// <#arguments#>
@property (nonatomic ,weak) UIView *bgView;
@property (nonatomic ,weak) UIImageView *iconImg;
@property (nonatomic ,weak) UILabel *titleLabel;
@property (nonatomic ,weak) UILabel *msgNumLabel;
@end
@implementation TabMessageTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self)
{
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.backgroundColor = KKClearColor;
[self subCellView];
}
return self;
}
-(void)setMsgTotalCount:(NSNumber *)msgTotalCount
{
_msgTotalCount = msgTotalCount;
self.msgNumLabel.hidden = msgTotalCount.integerValue > 0 ? NO : YES;
self.msgNumLabel.text = F(@"%@", msgTotalCount);
if (msgTotalCount.integerValue > 0)
{
CGFloat ww = msgTotalCount.integerValue > 9 && msgTotalCount.integerValue < 100 ? 25 : msgTotalCount.integerValue > 99 ? 32 : 20;
[self.msgNumLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.bgView.mas_right).inset(15);
make.centerY.equalTo(self.bgView);
make.size.mas_equalTo(CGSizeMake(ww, 20));
}];
}
}
- (void)setTitleStr:(NSString *)titleStr
{
_titleStr = titleStr;
self.titleLabel.text = titleStr;
}
- (void)setImageStr:(NSString *)imageStr
{
_imageStr = imageStr;
self.iconImg.image = ImageName_(imageStr);
}
- (void)subCellView
{
UIView *bgView = [UICommon ui_view:CGRectZero backgroundColor:KKWhiteColorColor cornerRadius:10 borderWidth:0 borderColor:KKWhiteColorColor];
self.bgView = bgView;
[self.contentView addSubview:bgView];
[bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.contentView).inset(15);
make.top.equalTo(self.contentView).offset(15);
make.bottom.equalTo(self.contentView.mas_bottom);
}];
UIImageView *iconImg = [UICommon ui_imageView:CGRectZero fileName:@""];
self.iconImg = iconImg;
[bgView addSubview:iconImg];
[iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(bgView).offset(15);
make.centerY.equalTo(bgView);
make.size.mas_equalTo(CGSizeMake(40, 40));
}];
UILabel *titleLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:Font_(15) textColor:KKTextBlackColor text:@"" Radius:0];
self.titleLabel = titleLabel;
[bgView addSubview:titleLabel];
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(iconImg.mas_right).offset(10);
make.centerY.equalTo(bgView);
}];
UILabel *msgNumLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:Font_(13) textColor:KKWhiteColorColor text:@"" Radius:10];
msgNumLabel.layer.borderWidth = 1.5;
msgNumLabel.layer.borderColor = KKWhiteColorColor.CGColor;
msgNumLabel.backgroundColor = RGB(254, 83, 71);
msgNumLabel.hidden = YES;
self.msgNumLabel = msgNumLabel;
[bgView addSubview:msgNumLabel];
[msgNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(bgView.mas_right).inset(15);
make.centerY.equalTo(bgView);
make.size.mas_equalTo(CGSizeMake(20, 20));
}];
}
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end