|
//
// 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] >= rect_screen.size.width -30) {
imageWidth = rect_screen.size.width-30;
}else{
imageWidth = [_imageBo.width floatValue];
}
imageHeight = [_imageBo.height floatValue];
NSString *imageId = getImageNameFromURL(_imageBo.url);
self.image.imageUrl = _imageBo.url;
self.image.imageId = imageId;
[self setLayout];
}
-(void)setLayout{
// CGFloat scale = imageHeight/imageWidth;
// self.image.frame = CGRectMake(CGRectGetWidth(self.contentView.bounds)/2- imageWidth/2, 10, imageWidth, 200*scale);
if ([[TPUserDefault instance].readModeStr intValue] == imageMode) {
[self.image remakeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.contentView.centerX);
make.width.mas_equalTo(imageWidth);
make.top.equalTo(self.contentView.top).offset(10);
make.bottom.equalTo(self.contentView.bottom).offset(-10);
}];
}else if ([[TPUserDefault instance].readModeStr intValue] == textMode) {
[self.image remakeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.contentView.centerX);
make.width.mas_equalTo(imageWidth);
make.top.equalTo(self.contentView.top);
make.height.equalTo(@0);
}];
}else {
if ([Remote IsEnableWIFI]) {
[self.image remakeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.contentView.centerX);
make.width.mas_equalTo(imageWidth);
make.top.equalTo(self.contentView.top).offset(10);
make.bottom.equalTo(self.contentView.bottom).offset(-10);
}];
}else {
[self.image remakeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.contentView.centerX);
make.width.mas_equalTo(imageWidth);
make.top.equalTo(self.contentView.top);
make.height.equalTo(@0);
}];
}
}
}
@end
|