No Description

LogisticsProgressCell.m 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. //
  2. // LogisticsCell.m
  3. // FirstLink
  4. //
  5. // Created by ascii on 15/5/29.
  6. // Copyright (c) 2015年 FirstLink. All rights reserved.
  7. //
  8. #import "LogisticsProgressCell.h"
  9. @implementation LogisticsProgressCell
  10. - (void)awakeFromNib {
  11. // Initialization code
  12. [super awakeFromNib];
  13. }
  14. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  15. [super setSelected:selected animated:animated];
  16. // Configure the view for the selected state
  17. }
  18. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  19. self = [super initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier];
  20. if (self) {
  21. [self addSubviewsForStyleProgress];
  22. }
  23. return self;
  24. }
  25. - (void)addSubviewsForStyleProgress {
  26. [self addCommonSubviews];
  27. WeakSelf(weakSelf);
  28. UIView *line = [self makeNewLine];
  29. [self.contentView addSubview:line];
  30. [line mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.left.equalTo(weakSelf.contentView).with.offset(26);
  32. make.top.equalTo(weakSelf.contentView).with.offset(0);
  33. make.bottom.equalTo(weakSelf.contentView).with.offset(0);
  34. make.width.mas_equalTo(1.0/[UIScreen mainScreen].scale);
  35. }];
  36. UIImageView *circle = [self makeCircle];
  37. [circle setImage:[UIImage imageNamed:@"LogisticsUnreceivedIcon"]];
  38. [self.contentView addSubview:circle];
  39. [circle mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.centerX.equalTo(line.mas_centerX);
  41. make.top.equalTo(weakSelf.contentView).with.offset(15);
  42. make.size.mas_equalTo(CGSizeMake(12, 12));
  43. }];
  44. }
  45. - (void)addCommonSubviews {
  46. WeakSelf(weakSelf);
  47. [self.contentView addSubview:self.logisticsTimeLabel];
  48. [self.logisticsTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.left.equalTo(weakSelf.contentView).with.offset(47);
  50. make.right.equalTo(weakSelf.contentView).with.offset(-15);
  51. make.bottom.equalTo(weakSelf.contentView).with.offset(-12);
  52. make.height.mas_equalTo(20);
  53. }];
  54. [self.contentView addSubview:self.logisticsTextLabel];
  55. [self.logisticsTextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.left.equalTo(weakSelf.contentView).with.offset(47);
  57. make.right.equalTo(weakSelf.contentView).with.offset(-15);
  58. make.top.equalTo(weakSelf.contentView).with.offset(15);
  59. make.bottom.equalTo(weakSelf.logisticsTimeLabel.mas_top).with.offset(-6);
  60. }];
  61. [self.contentView addSubview:self.horizontalLine];
  62. [self.horizontalLine mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.left.equalTo(weakSelf.contentView).with.offset(47);
  64. make.right.equalTo(weakSelf.contentView).with.offset(-15);
  65. make.top.equalTo(weakSelf.contentView);
  66. make.height.mas_equalTo(1.0/[UIScreen mainScreen].scale);
  67. }];
  68. }
  69. #pragma mark - Property
  70. - (UILabel *)logisticsTextLabel {
  71. if (!_logisticsTextLabel) {
  72. _logisticsTextLabel = [[UILabel alloc] init];
  73. _logisticsTextLabel.textColor = UIColorFromRGB(0x7a7a7a);
  74. _logisticsTextLabel.font = [UIFont systemFontOfSize:14];
  75. _logisticsTextLabel.numberOfLines = 0;
  76. _logisticsTextLabel.lineBreakMode = NSLineBreakByWordWrapping;
  77. }
  78. return _logisticsTextLabel;
  79. }
  80. - (UILabel *)logisticsTimeLabel {
  81. if (!_logisticsTimeLabel) {
  82. _logisticsTimeLabel = [[UILabel alloc] init];
  83. _logisticsTimeLabel.textColor = UIColorFromRGB(0x7a7a7a);
  84. _logisticsTimeLabel.font = [UIFont systemFontOfSize:13.0];
  85. // _logisticsTimeLabel.backgroundColor = [UIColor redColor];
  86. }
  87. return _logisticsTimeLabel;
  88. }
  89. - (UIView*)makeNewLine {
  90. UIView *view = [[UIView alloc] init];
  91. view.backgroundColor = UIColorFromRGB(0xe5e5e5);
  92. return view;
  93. }
  94. - (UIView *)horizontalLine {
  95. if (!_horizontalLine) {
  96. _horizontalLine = [self makeNewLine];
  97. }
  98. return _horizontalLine;
  99. }
  100. - (UIImageView*)makeCircle {
  101. UIImageView *circle = [[UIImageView alloc] init];
  102. return circle;
  103. }
  104. #pragma mark -
  105. + (CGFloat)titleHeightWith:(NSString *)title {
  106. return [FLStringHelper rectOfString:title
  107. font:[UIFont systemFontOfSize:14]
  108. width:(UISCREENWIDTH - 47 - 15)].size.height;
  109. }
  110. + (CGFloat)cellHeightWith:(NSString *)title {
  111. CGFloat otherHeight = (15 + 6 + 20 + 12 + 1);
  112. CGFloat titleHeight = [LogisticsProgressCell titleHeightWith:title];
  113. return (otherHeight + titleHeight);
  114. }
  115. @end