Aucune description

FKProSpecResCell.m 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. // FKProSpecResCell.m
  3. // FirstLink
  4. //
  5. // Created by jack on 16/8/12.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKProSpecResCell.h"
  9. #import "FKProDetailViewModel.h"
  10. @interface FKProSpecResCell ()
  11. @property (nonatomic, strong) UILabel *titleLabel;
  12. @property (nonatomic, strong) UILabel *specLabel;
  13. @property (nonatomic, strong) UIImageView *rightArrow;
  14. @end
  15. @implementation FKProSpecResCell
  16. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  17. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  18. [self addAllSubviews];
  19. self.selectionStyle = UITableViewCellSelectionStyleNone;
  20. self.contentView.backgroundColor = [UIColor whiteColor];
  21. }
  22. return self;
  23. }
  24. - (void)addAllSubviews{
  25. [self.contentView addSubview:self.titleLabel];
  26. [self.contentView addSubview:self.specLabel];
  27. [self.contentView addSubview:self.rightArrow];
  28. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  29. make.left.equalTo(self.contentView).offset(15);
  30. make.centerY.equalTo(self.contentView);
  31. }];
  32. [self.rightArrow mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.right.equalTo(self.contentView).offset(-15);
  34. make.centerY.equalTo(self.contentView);
  35. }];
  36. [self.specLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.right.equalTo(self.rightArrow.mas_left).offset(- 7);
  38. make.left.equalTo(self.titleLabel.mas_right).offset(10);
  39. make.centerY.equalTo(self.contentView);
  40. }];
  41. }
  42. - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath{
  43. if ([viewModel isKindOfClass:[FKProDetailViewModel class]]) {
  44. FKProDetailViewModel *detailModel = (FKProDetailViewModel *)viewModel;
  45. self.specLabel.text = detailModel.selectBuyItem.title;
  46. }
  47. }
  48. + (CGFloat)cellHeight{
  49. return 44.0f;
  50. }
  51. - (UILabel *)titleLabel{
  52. if (_titleLabel == nil) {
  53. _titleLabel = [[UILabel alloc]init];
  54. _titleLabel.textColor = UIColorFromRGB(0x666666);
  55. _titleLabel.font = [UIFont systemFontOfSize:14];
  56. _titleLabel.text = @"已选规格:";
  57. }
  58. return _titleLabel;
  59. }
  60. - (UILabel *)specLabel{
  61. if (_specLabel == nil) {
  62. _specLabel = [[UILabel alloc]init];
  63. _specLabel.textColor = UIColorFromRGB(0x333333);
  64. _specLabel.font = [UIFont systemFontOfSize:13];
  65. _specLabel.lineBreakMode = NSLineBreakByTruncatingTail;
  66. }
  67. return _specLabel;
  68. }
  69. - (UIImageView *)rightArrow{
  70. if (_rightArrow == nil) {
  71. _rightArrow = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"more_right_arrow"]];
  72. [_rightArrow setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  73. [_rightArrow setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  74. }
  75. return _rightArrow;
  76. }
  77. @end