澎湃iPad上线版本

letterInfoImageCell.m 2.1KB

    // // letterInfoImageCell.m // ThePaperHD // // Created by liyuan on 15/7/17. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "letterInfoImageCell.h" #import "AsyncImageView.h" @interface letterInfoImageCell(){ CGFloat imageWidth; CGFloat imageHeight; } @property(nonatomic, strong)AsyncImageView *image; @end @implementation letterInfoImageCell @synthesize imageBo = _imageBo; - (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.backgroundColor = [UIColor greenColor]; self.selectionStyle = UITableViewCellSelectionStyleNone; [self.contentView addSubview:self.image]; } return self; } #pragma mark -- view -(AsyncImageView *)image{ if (!_image) { _image = [[AsyncImageView alloc] initWithFrame:CGRectZero]; } return _image; } #pragma mark -- data -(void)setImageBo:(imageObjectBO *)bo{ _imageBo = bo; if ([_imageBo.width floatValue] >= messagePopSize.width -30) { imageWidth = messagePopSize.width-30; }else{ imageWidth = [_imageBo.width floatValue]; } imageHeight = [_imageBo.height floatValue]; self.image.imageUrl = _imageBo.url; [self layoutSubviews]; } -(void)layoutSubviews{ [super layoutSubviews]; CGFloat scale = imageHeight/imageWidth; self.image.frame = CGRectMake(CGRectGetWidth(self.contentView.bounds)/2- imageWidth/2, 15, imageWidth, 450*scale); // [self.image makeConstraints:^(MASConstraintMaker *make) { // CGFloat scale = imageHeight/imageWidth; // make.centerX.equalTo(self.contentView.centerX); // make.width.mas_equalTo(450); // make.height.mas_equalTo(450*scale); // make.top.equalTo(self.contentView.top); // }]; } @end