// // JXTHomeMessageCell.m // shiku_im // // Created by 123 on 2020/4/28. // Copyright © 2020 Reese. All rights reserved. // #import "JXTHomeMessageCell.h" #import "UIView+LK.h" @interface JXTHomeMessageCell() @property (nonatomic, strong)UIImageView *IMGHead; @property (nonatomic, weak)UILabel *contentL; @property (nonatomic,weak) UIView *line_view; @end @implementation JXTHomeMessageCell -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if(self= [super initWithStyle:style reuseIdentifier:reuseIdentifier]){ self.IMGHead = [[UIImageView alloc] init]; self.IMGHead.image = [UIImage imageNamed:@""]; self.IMGHead.layer.cornerRadius=5; self.IMGHead.layer.masksToBounds=YES; [self addSubview:self.IMGHead]; [self.IMGHead mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.mas_equalTo(self.centerY).mas_offset(0); make.left.mas_equalTo(15); make.width.mas_equalTo(52); make.height.mas_equalTo(52); }]; UILabel *contentL = [[UILabel alloc]init]; contentL.font=[UIFont systemFontOfSize:16 weight:UIFontWeightMedium]; contentL.textColor=[UIColor blackColor]; contentL.textAlignment=NSTextAlignmentLeft; contentL.numberOfLines=3; [self addSubview:contentL]; self.contentL=contentL; [contentL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.IMGHead.mas_right).mas_offset(15); make.centerY.mas_equalTo(self.IMGHead.centerY).mas_offset(0); }]; UILabel *countTipL = [[UILabel alloc]init]; countTipL.font=[UIFont systemFontOfSize:11 weight:UIFontWeightMedium]; countTipL.textColor=[UIColor whiteColor]; countTipL.backgroundColor=[UIColor redColor]; countTipL.textAlignment=NSTextAlignmentCenter; countTipL.layer.cornerRadius=9; countTipL.layer.masksToBounds=YES; countTipL.hidden=YES; [self addSubview:countTipL]; self.countTipL=countTipL; [countTipL mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-15); make.centerY.mas_equalTo(self.IMGHead.centerY).mas_offset(0); make.width.mas_equalTo(18); make.height.mas_equalTo(18); }]; UILabel *guanL = [[UILabel alloc]init]; guanL.font=[UIFont systemFontOfSize:12 weight:UIFontWeightMedium]; guanL.backgroundColor=[UIColor blueColor]; guanL.textColor=[UIColor whiteColor]; guanL.text=@"官方"; guanL.textAlignment=NSTextAlignmentCenter; guanL.layer.cornerRadius=8; guanL.layer.masksToBounds=YES; guanL.hidden=YES; [self addSubview:guanL]; self.guanL=guanL; [guanL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.contentL.mas_right).mas_offset(15); make.centerY.mas_equalTo(self.contentL.centerY).mas_offset(0); make.width.mas_equalTo(40); make.height.mas_equalTo(18); }]; UIView *line_view = [[UIView alloc]init]; line_view.backgroundColor=kRGBColor(245, 245, 245); [self addSubview:line_view]; self.line_view=line_view; [line_view mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(contentL.mas_left).mas_offset(0); make.right.mas_equalTo(0); make.bottom.mas_equalTo(0); make.height.mas_equalTo(1); }]; } return self; } +(instancetype)cellWithTableView:(UITableView *)tableView{ static NSString *ID = @"JXTHomeMessageCell"; JXTHomeMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; if (cell == nil) { cell = [[JXTHomeMessageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID]; } cell.selectionStyle=UITableViewCellSelectionStyleNone; return cell; } - (void)createMesageTip:(JXTMessageModel *)teachModel and:(NSString *)countTip and:(NSIndexPath *)indexPath { _teachModel=teachModel; self.IMGHead.image=[UIImage imageNamed:teachModel.jx_img]; self.contentL.text=[NSString stringWithFormat:@"%@",teachModel.name]; if ([teachModel.name isEqualToString:@"即信"]) { [_line_view mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(_contentL.mas_left).mas_offset(0); make.right.mas_equalTo(0); make.bottom.mas_equalTo(0); make.height.mas_equalTo(1); }]; }else{ [_line_view mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(_contentL.mas_left).mas_offset(0); make.right.mas_equalTo(0); make.bottom.mas_equalTo(0); make.height.mas_equalTo(15); }]; self.line_view.hidden=NO; } if ([teachModel.name isEqualToString:@"即信"]) { self.guanL.hidden=NO; }else{ self.guanL.hidden=YES; } if (indexPath.row==0&& [countTip integerValue]>0&&countTip!=nil) { self.countTipL.hidden=NO; self.countTipL.text=[NSString stringWithFormat:@"%@",countTip]; }else{ self.countTipL.hidden=YES; } } -(void)setTeachModel:(JXTMessageModel *)teachModel{ _teachModel=teachModel; self.IMGHead.image=[UIImage imageNamed:teachModel.jx_img]; self.contentL.text=[NSString stringWithFormat:@"%@",teachModel.name]; // if ([teachModel.name isEqualToString:@"通讯录"]) { // // self.line_view.hidden=YES; // }else{ // self.line_view.hidden=NO; // } } -(void)setFrame:(CGRect)frame{ frame.origin.y+=1; frame.size.height-=1; [super setFrame:frame]; } @end