Bez popisu

LogisticsSuccessCell.m 4.3KB

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