Geen omschrijving

FKProTitleCell.m 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //
  2. // FKProTitleCell.m
  3. // FirstLink
  4. //
  5. // Created by jack on 16/8/12.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKProTitleCell.h"
  9. #import "FKProDetailViewModel.h"
  10. @interface FKProTitleCell ()
  11. @property (nonatomic, strong) UIView *topLine;
  12. @property (nonatomic, strong) UIView *vertLine;
  13. @property (nonatomic, strong) UIButton *priceWarnBtn;
  14. @end
  15. @implementation FKProTitleCell
  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.priceWarnBtn];
  27. [self.contentView addSubview:self.priceWarnActBtn];
  28. [self.contentView addSubview:self.vertLine];
  29. [self.contentView addSubview:self.topLine];
  30. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.left.equalTo(self.contentView).offset(15);
  32. make.right.equalTo(self.vertLine.mas_left).offset(- 15);
  33. make.bottom.top.equalTo(self.contentView);
  34. }];
  35. [self.priceWarnBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.centerX.equalTo(self.contentView.mas_right).offset(- 30);
  37. make.top.equalTo(self.contentView).offset(12);
  38. make.width.height.mas_equalTo(35);
  39. }];
  40. [self.vertLine mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.right.equalTo(self.priceWarnBtn.mas_left).offset(- 12.5);
  42. make.size.mas_equalTo(CGSizeMake(0.5, 30));
  43. make.centerY.equalTo(self.priceWarnBtn);
  44. }];
  45. [self.priceWarnActBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.left.equalTo(self.vertLine);
  47. make.top.right.bottom.equalTo(self.contentView);
  48. }];
  49. [self.topLine mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.left.top.right.equalTo(self.contentView);
  51. make.height.mas_equalTo(0.5);
  52. }];
  53. }
  54. + (CGFloat)cellHeightForTitle:(NSString *)title{
  55. CGFloat textH = [FLStringHelper sizeOfAttributeString:title
  56. lineSpace:2.4
  57. width:UISCREENWIDTH - 85
  58. font:[UIFont systemFontOfSize:15]
  59. maxRow:0].height;
  60. return MAX(50, textH + 17);
  61. }
  62. //+ (CGFloat)cellHeight{
  63. // return 62.0f;
  64. //}
  65. - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath{
  66. if ([viewModel isKindOfClass:[FKProDetailViewModel class]]) {
  67. FKProDetailViewModel *detailModel = (FKProDetailViewModel *)viewModel;
  68. self.titleLabel.attributedText = [FLStringHelper attStringWithText:detailModel.dataItem.productInfo.name lineSpace:2.4f];
  69. }
  70. }
  71. #pragma mark - property
  72. - (UILabel *)titleLabel{
  73. if (_titleLabel == nil) {
  74. _titleLabel = [[UILabel alloc]init];
  75. _titleLabel.textColor = UIColorFromRGB(0x4a4a4a);
  76. _titleLabel.font = [UIFont systemFontOfSize:15];
  77. _titleLabel.numberOfLines = 0;
  78. _titleLabel.textAlignment = NSTextAlignmentCenter;
  79. }
  80. return _titleLabel;
  81. }
  82. - (UIButton *)priceWarnBtn{
  83. if (_priceWarnBtn == nil) {
  84. _priceWarnBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  85. [_priceWarnBtn setTitle:@"降价\n通知" forState:UIControlStateNormal];
  86. [_priceWarnBtn setTitleColor:UIColorFromRGB(0x333333) forState:UIControlStateNormal];
  87. _priceWarnBtn.titleLabel.font = [UIFont systemFontOfSize:10];
  88. _priceWarnBtn.titleLabel.numberOfLines = 0;
  89. _priceWarnBtn.layer.cornerRadius = 17.5f;
  90. _priceWarnBtn.layer.borderColor = UIColorFromRGB(0x999999).CGColor;
  91. _priceWarnBtn.layer.borderWidth = 0.5;
  92. _priceWarnBtn.layer.masksToBounds = YES;
  93. _priceWarnBtn.userInteractionEnabled = NO;
  94. }
  95. return _priceWarnBtn;
  96. }
  97. - (UIButton *)priceWarnActBtn{
  98. if (_priceWarnActBtn == nil) {
  99. _priceWarnActBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  100. }
  101. return _priceWarnActBtn;
  102. }
  103. - (UIView *)vertLine{
  104. if (_vertLine == nil) {
  105. _vertLine = [[UIView alloc]init];
  106. _vertLine.backgroundColor = UIColorFromRGB(0xcccccc);
  107. }
  108. return _vertLine;
  109. }
  110. - (UIView *)topLine{
  111. if (_topLine == nil) {
  112. _topLine = [[UIView alloc]init];
  113. _topLine.backgroundColor = UIColorFromRGB(0xe5e5e5);
  114. }
  115. return _topLine;
  116. }
  117. @end