Nenhuma Descrição

FKProWarnTitleCell.m 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // FKProWarnTitleCell.m
  3. // FirstLink
  4. //
  5. // Created by jack on 16/8/16.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKProWarnTitleCell.h"
  9. #import "FKProDetailViewModel.h"
  10. @interface FKProWarnTitleCell ()
  11. @property (nonatomic, strong) UIView *bottomLine;
  12. @end
  13. @implementation FKProWarnTitleCell
  14. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  15. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  16. [self addAllSubviews];
  17. self.selectionStyle = UITableViewCellSelectionStyleNone;
  18. self.contentView.backgroundColor = [UIColor whiteColor];
  19. }
  20. return self;
  21. }
  22. + (CGFloat)cellHeightForTitle:(NSString *)title lastRow:(BOOL)lastRow{
  23. CGFloat textH = [FLStringHelper sizeOfAttributeString:title
  24. font:[UIFont systemFontOfSize:13]
  25. width:UISCREENWIDTH - 30
  26. maxRow:INT_MAX].height;
  27. if (lastRow) return textH + 45;
  28. return textH + 30;
  29. }
  30. - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath{
  31. if ([viewModel isKindOfClass:[FKProDetailViewModel class]]) {
  32. FKProDetailViewModel *detailModel = (FKProDetailViewModel *)viewModel;
  33. NSString *title = [detailModel.tipsItem buyWarnTitleForIndexPath:indexPath];
  34. self.titleLabel.text = title;
  35. NSInteger count = [detailModel numberOfRowsInSection:indexPath.section tableType:kProTableTypeDown];
  36. self.bottomLine.hidden = NO;
  37. if (indexPath.row == count - 1) self.bottomLine.hidden = YES;
  38. }
  39. }
  40. - (void)addAllSubviews{
  41. [self.contentView addSubview:self.titleLabel];
  42. [self.contentView addSubview:self.bottomLine];
  43. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.top.equalTo(self.contentView).offset(10);
  45. make.left.equalTo(self.contentView).offset(15);
  46. make.right.equalTo(self.contentView).offset(-15);
  47. // make.centerY.equalTo(self.contentView);
  48. }];
  49. [self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.left.equalTo(self.contentView).offset(15);
  51. make.right.equalTo(self.contentView).offset(-15);
  52. make.bottom.equalTo(self.contentView);
  53. make.height.mas_equalTo(0.5);
  54. }];
  55. }
  56. - (UILabel *)titleLabel{
  57. if (_titleLabel == nil) {
  58. _titleLabel = [[UILabel alloc]init];
  59. _titleLabel.font = [UIFont systemFontOfSize:13];
  60. _titleLabel.textColor = UIColorFromRGB(0x666666);
  61. _titleLabel.numberOfLines = 0;
  62. }
  63. return _titleLabel;
  64. }
  65. - (UIView *)bottomLine {
  66. if (_bottomLine == nil) {
  67. _bottomLine = [[UIView alloc] init];
  68. _bottomLine.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"grey_lines"]];
  69. }
  70. return _bottomLine;
  71. }
  72. @end