澎湃iPad上线版本

letterCell.m 5.9KB

    // // letterCell.m // ThePaperHD // // Created by liyuan on 15/7/15. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "letterCell.h" #import "AsyncImageView.h" @interface letterCell(){ CGFloat titleHeight; } @property(nonatomic, strong)AsyncImageView *headImg; @property(nonatomic, strong)UIImageView *vImg; @property(nonatomic, strong)UILabel *nameLabel; @property(nonatomic, strong)UIImageView *timeIcon; @property(nonatomic, strong)UILabel *timeLabel; @property(nonatomic, strong)UILabel *topicLabel; @property(nonatomic, strong)UILabel *InfoLabel; @property(nonatomic, strong)UIView *line; @end @implementation letterCell @synthesize letterBo = _letterBo; - (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.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; self.selectionStyle = UITableViewCellSelectionStyleNone; [self.contentView addSubview:self.headImg]; [self.contentView addSubview:self.vImg]; [self.contentView addSubview:self.nameLabel]; [self.contentView addSubview:self.timeIcon]; [self.contentView addSubview:self.timeLabel]; [self.contentView addSubview:self.topicLabel]; [self.contentView addSubview:self.InfoLabel]; [self.contentView addSubview:self.line]; } return self; } #pragma mark -- view -(AsyncImageView *)headImg{ if (!_headImg) { _headImg = [[AsyncImageView alloc] initWithFrame:CGRectZero]; _headImg.layer.cornerRadius = 15; _headImg.clipsToBounds = YES; _headImg.isHaveWaterPrint = NO; } return _headImg; } -(UIImageView *)vImg{ if (!_vImg) { _vImg = [[UIImageView alloc] initWithFrame:CGRectZero]; _vImg.image = Image(@"topic/vipIcon.png"); _vImg.hidden = YES; } return _vImg; } -(UILabel *)nameLabel{ if (!_nameLabel) { _nameLabel = [[UILabel alloc] initWithFrame:CGRectZero]; _nameLabel.font = appFont(12, NO); _nameLabel.textColor = [UIColor colorWithHexString:BLUECOLOR]; _nameLabel.backgroundColor = [UIColor clearColor]; } return _nameLabel; } -(UIImageView *)timeIcon{ if (!_timeIcon) { _timeIcon = [[UIImageView alloc] initWithFrame:CGRectZero]; _timeIcon.image = Image(@"setting/showTime.png"); } return _timeIcon; } -(UILabel *)timeLabel{ if (!_timeLabel) { _timeLabel = [[UILabel alloc] initWithFrame:CGRectZero]; _timeLabel.textColor = [UIColor colorWithHexString:TextLightGray]; _timeLabel.font = appFont(10, NO); _timeLabel.backgroundColor = [UIColor clearColor]; } return _timeLabel; } -(UILabel *)topicLabel{ if (!_topicLabel) { _topicLabel = [[UILabel alloc] initWithFrame:CGRectZero]; _topicLabel.font = appFont(17, NO); _topicLabel.textColor = [UIColor colorWithHexString:TextBlack]; _topicLabel.backgroundColor = [UIColor clearColor]; _topicLabel.lineBreakMode = NSLineBreakByWordWrapping; _topicLabel.numberOfLines = 0; } return _topicLabel; } -(UILabel *)InfoLabel{ if (!_InfoLabel) { _InfoLabel = [[UILabel alloc] initWithFrame:CGRectZero]; _InfoLabel.textColor = [UIColor colorWithHexString:BLUECOLOR]; _InfoLabel.font = appFont(10, NO); _InfoLabel.backgroundColor = [UIColor clearColor]; _InfoLabel.text = @"查看详情 >"; _InfoLabel.textAlignment = NSTextAlignmentRight; } return _InfoLabel; } -(UIView *)line{ if (!_line) { _line = [[UIView alloc] initWithFrame:CGRectZero]; _line.backgroundColor = [UIColor colorWithHexString:LINECOLOR]; } return _line; } #pragma mark -- setData -(void)setLetterBo:(letterBO *)bo{ _letterBo = bo; userBO *user = setJsonDicToDataModel(bo.userInfo, [userBO class]); self.headImg.imageUrl = user.pic; if ([user.isAuth integerValue] ==1) { self.vImg.hidden = NO; }else{ self.vImg.hidden = YES; } if(!isBlankString(user.sname)){ self.nameLabel.text = [NSString stringWithFormat:@"%@:",user.sname]; }else{ self.nameLabel.text = @""; } self.timeLabel.text = bo.pubTime; self.topicLabel.text = bo.title; [self layoutSubviews]; } -(void)layoutSubviews{ [super layoutSubviews]; self.headImg.frame = CGRectMake(15, 27,30,30); self.vImg.frame = CGRectMake(CGRectGetMaxX(self.headImg.frame)-10, CGRectGetMaxY(self.headImg.frame)-10, 10, 10); self.nameLabel.frame = CGRectMake(CGRectGetMaxX(self.headImg.frame)+10, CGRectGetMinY(self.headImg.frame), CGRectGetWidth(self.contentView.bounds), 20); self.timeIcon.frame = CGRectMake(CGRectGetMinX(self.nameLabel.frame), CGRectGetMaxY(self.nameLabel.frame), 10, 10); self.timeLabel.frame = CGRectMake(CGRectGetMaxX(self.timeIcon.frame)+10, CGRectGetMinY(self.timeIcon.frame), CGRectGetWidth(self.contentView.bounds)-CGRectGetMaxX(self.timeIcon.frame), 10); CGSize titleSize = [self.topicLabel sizeThatFits:CGSizeMake(CGRectGetWidth(self.contentView.bounds)-30, 0)]; titleHeight = titleSize.height; self.topicLabel.frame = CGRectMake(15, CGRectGetMaxY(self.headImg.frame)+5, CGRectGetWidth(self.contentView.bounds)-30, titleHeight); self.InfoLabel.frame = CGRectMake(CGRectGetWidth(self.contentView.bounds)-15-57, CGRectGetMaxY(self.topicLabel.frame)+5, 57, 10); self.line.frame = CGRectMake(15, CGRectGetHeight(self.contentView.bounds)-2, CGRectGetWidth(self.contentView.bounds)-30, 1); } @end