// // LogisticsCell.m // FirstLink // // Created by ascii on 15/5/29. // Copyright (c) 2015年 FirstLink. All rights reserved. // #import "LogisticsProgressCell.h" @implementation LogisticsProgressCell - (void)awakeFromNib { // Initialization code [super awakeFromNib]; } - (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:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier]; if (self) { [self addSubviewsForStyleProgress]; } return self; } - (void)addSubviewsForStyleProgress { [self addCommonSubviews]; WeakSelf(weakSelf); UIView *line = [self makeNewLine]; [self.contentView addSubview:line]; [line mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(weakSelf.contentView).with.offset(26); make.top.equalTo(weakSelf.contentView).with.offset(0); make.bottom.equalTo(weakSelf.contentView).with.offset(0); make.width.mas_equalTo(1.0/[UIScreen mainScreen].scale); }]; UIImageView *circle = [self makeCircle]; [circle setImage:[UIImage imageNamed:@"LogisticsUnreceivedIcon"]]; [self.contentView addSubview:circle]; [circle mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(line.mas_centerX); make.top.equalTo(weakSelf.contentView).with.offset(15); make.size.mas_equalTo(CGSizeMake(12, 12)); }]; } - (void)addCommonSubviews { WeakSelf(weakSelf); [self.contentView addSubview:self.logisticsTimeLabel]; [self.logisticsTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(weakSelf.contentView).with.offset(47); make.right.equalTo(weakSelf.contentView).with.offset(-15); make.bottom.equalTo(weakSelf.contentView).with.offset(-12); make.height.mas_equalTo(20); }]; [self.contentView addSubview:self.logisticsTextLabel]; [self.logisticsTextLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(weakSelf.contentView).with.offset(47); make.right.equalTo(weakSelf.contentView).with.offset(-15); make.top.equalTo(weakSelf.contentView).with.offset(15); make.bottom.equalTo(weakSelf.logisticsTimeLabel.mas_top).with.offset(-6); }]; [self.contentView addSubview:self.horizontalLine]; [self.horizontalLine mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(weakSelf.contentView).with.offset(47); make.right.equalTo(weakSelf.contentView).with.offset(-15); make.top.equalTo(weakSelf.contentView); make.height.mas_equalTo(1.0/[UIScreen mainScreen].scale); }]; } #pragma mark - Property - (UILabel *)logisticsTextLabel { if (!_logisticsTextLabel) { _logisticsTextLabel = [[UILabel alloc] init]; _logisticsTextLabel.textColor = UIColorFromRGB(0x7a7a7a); _logisticsTextLabel.font = [UIFont systemFontOfSize:14]; _logisticsTextLabel.numberOfLines = 0; _logisticsTextLabel.lineBreakMode = NSLineBreakByWordWrapping; } return _logisticsTextLabel; } - (UILabel *)logisticsTimeLabel { if (!_logisticsTimeLabel) { _logisticsTimeLabel = [[UILabel alloc] init]; _logisticsTimeLabel.textColor = UIColorFromRGB(0x7a7a7a); _logisticsTimeLabel.font = [UIFont systemFontOfSize:13.0]; // _logisticsTimeLabel.backgroundColor = [UIColor redColor]; } return _logisticsTimeLabel; } - (UIView*)makeNewLine { UIView *view = [[UIView alloc] init]; view.backgroundColor = UIColorFromRGB(0xe5e5e5); return view; } - (UIView *)horizontalLine { if (!_horizontalLine) { _horizontalLine = [self makeNewLine]; } return _horizontalLine; } - (UIImageView*)makeCircle { UIImageView *circle = [[UIImageView alloc] init]; return circle; } #pragma mark - + (CGFloat)titleHeightWith:(NSString *)title { return [FLStringHelper rectOfString:title font:[UIFont systemFontOfSize:14] width:(UISCREENWIDTH - 47 - 15)].size.height; } + (CGFloat)cellHeightWith:(NSString *)title { CGFloat otherHeight = (15 + 6 + 20 + 12 + 1); CGFloat titleHeight = [LogisticsProgressCell titleHeightWith:title]; return (otherHeight + titleHeight); } @end