// // trackContentCell.m // ThePaperHD // // Created by scar1900 on 15/3/31. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "trackContentCell.h" #import "AsyncImageView.h" @interface trackContentCell() { CGFloat titleHeight; } @property(nonatomic, strong)UIView *lineView; @property(nonatomic, strong)AsyncImageView *imgView; @property(nonatomic, strong)UILabel *titleLabel; @property(nonatomic, strong)UILabel *bottomLabel; @property(nonatomic, strong)UIView *selectView; @end @implementation trackContentCell @synthesize listBO; @synthesize trackBO; - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; self.selectionStyle = UITableViewCellSelectionStyleGray; self.selectedBackgroundView = self.selectView; self.clipsToBounds = YES; [self addSubview:self.imgView]; [self addSubview:self.titleLabel]; [self addSubview:self.bottomLabel]; [self addSubview:self.lineView]; } return self; } - (UIView *)selectView { if (!_selectView) { _selectView = [[UIView alloc]initWithFrame:CGRectZero]; _selectView.backgroundColor = [UIColor colorWithHexString:LINECOLOR]; } return _selectView; } - (void)setListBO:(listContObjectVO *)listInfo andTrackBO:(trackerInfoBO *)trackInfo { self.listBO = listInfo; self.trackBO = trackInfo; self.imgView.imageUrl = listInfo.pic; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSString *titleStr = listInfo.name; titleHeight = heightForString(titleStr, self.titleLabel.font, 763/2, NSLineBreakByWordWrapping); NSString *bottomStr = [NSString stringWithFormat:@"%@ %@",listInfo.nodeInfo[@"name"],listInfo.pubTime]; dispatch_async(dispatch_get_main_queue(), ^{ self.titleLabel.text = titleStr; self.bottomLabel.text = bottomStr; [self layoutSubviews]; }); }); } - (UIView*)lineView { if (!_lineView) { _lineView = [[UIView alloc]initWithFrame:CGRectZero]; _lineView.backgroundColor = [UIColor colorWithHexString:LINECOLOR]; } return _lineView; } - (AsyncImageView*)imgView { if (!_imgView) { _imgView = [[AsyncImageView alloc]initWithFrame:CGRectZero]; } return _imgView; } - (UILabel*)titleLabel { if (!_titleLabel) { _titleLabel = [[UILabel alloc]initWithFrame:CGRectZero]; _titleLabel.font = appFont(17, NO); _titleLabel.textColor = [UIColor colorWithHexString:TextBlack]; _titleLabel.textAlignment = NSTextAlignmentLeft; _titleLabel.backgroundColor = [UIColor clearColor]; _titleLabel.lineBreakMode = NSLineBreakByWordWrapping; _titleLabel.numberOfLines = 0; } return _titleLabel; } - (UILabel*)bottomLabel { if (!_bottomLabel) { _bottomLabel = [[UILabel alloc]initWithFrame:CGRectZero]; _bottomLabel.font = appFont(10, NO); _bottomLabel.textColor = [UIColor colorWithHexString:LIGHTGRAY]; _bottomLabel.textAlignment = NSTextAlignmentLeft; _bottomLabel.backgroundColor = [UIColor clearColor]; } return _bottomLabel; } - (void)layoutSubviews { [super layoutSubviews]; self.imgView.frame = CGRectMake(15, CGRectGetHeight(self.bounds)/2-30, 60,60); self.lineView.frame = CGRectMake(15, CGRectGetHeight(self.bounds)-1, CGRectGetWidth(self.bounds)-30, 1); self.titleLabel.frame = CGRectMake(CGRectGetMaxX(self.imgView.frame)+12, CGRectGetMinY(self.imgView.frame), 763/2, titleHeight); self.bottomLabel.frame = CGRectMake(CGRectGetMinX(self.titleLabel.frame), CGRectGetMaxY(self.imgView.frame)-10, 763/2, 10); } - (void)awakeFromNib { // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end