// // myAttentionCell.m // ThePaperHD // // Created by liyuan on 15/4/23. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "myAttentionCell.h" #import "userBO.h" @interface myAttentionCell(){ CGFloat titleHeight; CGFloat labelWidth; } @property(nonatomic,strong)UIView *backView; @property(nonatomic,strong)UILabel *auth; @property(nonatomic,strong)UILabel *title; @property(nonatomic,strong)UILabel *statu; @property(nonatomic,strong)UILabel *time; @property(nonatomic,strong)UIView *line; @property(nonatomic, strong)UILabel *markLabel; @property(nonatomic, strong)UIView *selectView; @end @implementation myAttentionCell - (void)awakeFromNib { // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.selectionStyle = UITableViewCellSelectionStyleGray; self.clipsToBounds = NO; self.contentView.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; self.backgroundColor =[UIColor colorWithHexString:BackGroundColor]; self.selectedBackgroundView = self.selectView; [self.contentView addSubview:self.backView]; [self.backView addSubview:self.auth]; [self.backView addSubview:self.title]; [self.backView addSubview:self.statu]; [self.backView addSubview:self.time]; [self.backView addSubview:self.line]; [self.backView addSubview:self.markLabel]; } return self; } - (UIView *)selectView { if (!_selectView) { _selectView = [[UIView alloc]initWithFrame:CGRectZero]; _selectView.backgroundColor = [UIColor colorWithHexString:LINECOLOR]; } return _selectView; } -(void) setData:(TopicInfoBO *)topInfo{ userBO *user = setJsonDicToDataModel(topInfo.userInfo, [userBO class]); self.auth.text = [NSString stringWithFormat:@"%@:",user.sname]; //话题:我的关注话题列表中未读数及红点标志位置不统一,要求统一格式显示(bug:4288)将40改成25 labelWidth = widthForString(topInfo.title, self.title.font, 25, self.title.lineBreakMode); if (labelWidth <= gambitCenterPopSize.width-20) {//单行 titleHeight = 25; }else{//多行 labelWidth = gambitCenterPopSize.width-30; titleHeight = heightForString(topInfo.title, self.title.font, gambitCenterPopSize.width-30, self.title.lineBreakMode); } self.title.text = topInfo.title; self.time.text = topInfo.publishTime; self.statu.text = [self statuName:topInfo]; NSString *newNum = topInfo.unNums; if ([newNum intValue] >0 ) { self.markLabel.hidden = NO; self.markLabel.text = newNum; }else { self.markLabel.hidden = YES; self.markLabel.text = @"0"; } [self layoutSubviews]; } //状态:0- 已提交待审核;1- 进行中;2- 审核不通过;3- 关闭 -(NSString *)statuName:(TopicInfoBO *)topic{ NSString *str; if ([topic.status integerValue] ==0) { str = @"待审核"; self.time.hidden = YES; }else if ([topic.status integerValue] ==1) { if ([topic.replyedNum integerValue] <=0) {//【需求】话题:增加提问征集中的状态(bug:4323) str = @"提问征集中"; }else{ str = @"进行中..."; } self.time.hidden = NO; }else if ([topic.status integerValue] ==2) { str = @"未通过"; self.time.hidden = YES; }else if ([topic.status integerValue] ==3) { str = @"已关闭提问"; self.time.hidden = NO; } // switch ([statu.status integerValue]) { // case 0: // str = @"待审核"; // self.time.hidden = YES; // self.errorIcon.hidden = YES; // break; // case 1: // str = @"进行中..."; // self.time.hidden = NO; // self.errorIcon.hidden = YES; // break; // case 2: // str = @"未通过"; // self.time.hidden = YES; // self.errorIcon.hidden = NO; // break; // case 3: // str = @"已关闭提问"; // self.time.hidden = NO; // self.errorIcon.hidden = YES; // break; // default: // break; // } return str; } #pragma mark - view -(UIView *)backView{ if (!_backView) { _backView = [[UIView alloc] init]; } return _backView; } -(UILabel *)auth{ if (!_auth) { _auth = [[UILabel alloc] init]; _auth.textColor = [UIColor colorWithHexString:BLUECOLOR]; _auth.font = appFont(17, NO); _auth.backgroundColor = [UIColor clearColor]; } return _auth; } -(UILabel *)title{ if (!_title) { _title = [[UILabel alloc] init]; _title.textColor = [UIColor colorWithHexString:TextBlack]; _title.font = appFont(18, NO); _title.lineBreakMode = NSLineBreakByWordWrapping; _title.numberOfLines = 0; _title.backgroundColor = [UIColor clearColor]; } return _title; } -(UILabel *)statu{ if (!_statu) { _statu = [[UILabel alloc]init]; _statu.textColor = [UIColor colorWithHexString:TextGray]; _statu.font = appFont(11, NO); _statu.backgroundColor = [UIColor clearColor]; } return _statu; } -(UILabel *)time{ if (!_time) { _time = [[UILabel alloc]init]; _time.textAlignment = NSTextAlignmentRight; _time.textColor = [UIColor colorWithHexString:TextGray]; _time.font = appFont(11, NO); _time.backgroundColor = [UIColor clearColor]; } return _time; } -(UIView *)line{ if (!_line) { _line = [[UIView alloc] init]; _line.backgroundColor = [UIColor colorWithHexString:LINECOLOR]; } return _line; } - (UILabel*)markLabel { if (!_markLabel) { _markLabel = [[UILabel alloc]initWithFrame:CGRectZero]; _markLabel.backgroundColor = [UIColor colorWithHexString:@"0xc32128"]; _markLabel.layer.cornerRadius = 11/2; _markLabel.clipsToBounds = YES; _markLabel.textAlignment = NSTextAlignmentCenter; _markLabel.textColor = [UIColor whiteColor]; _markLabel.font = appFont(7, NO); _markLabel.hidden = YES; } return _markLabel; } -(void)layoutSubviews{ [super layoutSubviews]; if (self.isEditing) { [self sendSubviewToBack:self.contentView]; } self.backView.frame = self.contentView.bounds; self.auth.frame = CGRectMake(15, 10, gambitCenterPopSize.width-30, 25); // self.title.frame = CGRectMake(15, 40, gambitCenterPopSize.width -30,titleHeight); self.title.frame = CGRectMake(15, 40, labelWidth,titleHeight); self.statu.frame = CGRectMake(15, CGRectGetMaxY(self.title.frame), 200, 30); self.time.frame = CGRectMake(CGRectGetMaxX(self.backView.bounds)-115, CGRectGetMaxY(self.title.frame), 100, 30); self.line.frame = CGRectMake(15, CGRectGetMaxY(self.contentView.bounds)-1, gambitCenterPopSize.width-30, 1); self.markLabel.frame = CGRectMake(CGRectGetMaxX(self.title.frame)-5, CGRectGetMinY(self.title.frame)-5, 11, 11); } @end