澎湃iPad上线版本

collectContentCell.m 4.4KB

    // // collectContentCell.m // ThePaperHD // // Created by liyuan on 15/4/13. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "collectContentCell.h" #import "AsyncImageView.h" @interface collectContentCell() { CGFloat titleHeight; } @property(nonatomic, strong)UIView *backView; @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 collectContentCell - (void)awakeFromNib { // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } - (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.contentView addSubview:self.backView]; [self.backView addSubview:self.imgView]; [self.backView addSubview:self.titleLabel]; [self.backView addSubview:self.bottomLabel]; [self.backView 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{ 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*)backView { if (!_backView) { _backView = [[UIView alloc]initWithFrame:CGRectZero]; _backView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin; } return _backView; } - (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.lineBreakMode = NSLineBreakByWordWrapping; _titleLabel.numberOfLines = 0; _titleLabel.backgroundColor = [UIColor clearColor]; } 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]; if (self.isEditing) { [self sendSubviewToBack:self.contentView]; } self.backView.frame = CGRectMake(0, 0, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds)); 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); } @end