口袋优选

KBSignInTableViewCell.m 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. //
  2. // KBSignInTableViewCell.m
  3. // YouHuiProject
  4. //
  5. // Created by jcymac on 2018/10/12.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBSignInTableViewCell.h"
  9. @implementation KBSignInTableViewCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. // Initialization code
  13. }
  14. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  15. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  16. if (self) {
  17. self.backgroundColor = [UIColor clearColor];
  18. self.contentView.backgroundColor = [UIColor clearColor];
  19. [self makeUI];
  20. }
  21. return self;
  22. }
  23. - (void)makeUI {
  24. [self.contentView addSubview:self.lineView];
  25. self.leftImageView = [[UIImageView alloc]init];
  26. [self.contentView addSubview:self.leftImageView];
  27. [self.contentView addSubview:self.contentLable];
  28. [self.contentView addSubview:self.rightBtn];
  29. [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.left.mas_equalTo(FITSIZE(15));
  31. make.right.mas_equalTo(-FITSIZE(15));
  32. make.top.mas_equalTo(0);
  33. make.height.mas_equalTo(1);
  34. }];
  35. [self.leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.mas_equalTo(FITSIZE(13));
  37. make.width.mas_equalTo(FITSIZE(43));
  38. make.height.mas_equalTo(FITSIZE(50));
  39. make.centerY.mas_equalTo(self.contentView.mas_centerY);
  40. }];
  41. [self.rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.right.mas_equalTo(-FITSIZE(10));
  43. make.width.mas_equalTo(FITSIZE(90));
  44. make.height.mas_equalTo(FITSIZE(30));
  45. make.centerY.mas_equalTo(self.contentView.mas_centerY);
  46. }];
  47. [self.contentLable mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.left.mas_equalTo(self.leftImageView.mas_right).offset(FITSIZE(10));
  49. make.right.mas_equalTo(self.rightBtn.mas_left).offset(5);
  50. make.height.mas_equalTo(20);
  51. make.centerY.mas_equalTo(self.contentView.mas_centerY);
  52. }];
  53. }
  54. - (UIButton*)rightBtn {
  55. if (!_rightBtn) {
  56. _rightBtn = [[UIButton alloc]init];
  57. _rightBtn.layer.borderWidth = 1;
  58. _rightBtn.layer.borderColor = [UIColor colorWithHexString:@"#FF5266"].CGColor;
  59. _rightBtn.layer.masksToBounds = YES;
  60. _rightBtn.layer.cornerRadius = FITSIZE(16);
  61. }
  62. return _rightBtn;
  63. }
  64. - (UILabel *)contentLable {
  65. if (!_contentLable) {
  66. _contentLable = [[UILabel alloc] init];
  67. _contentLable.textColor = [UIColor colorWithHexString:@"#F9041C"];
  68. _contentLable.font = [UIFont systemFontOfSize:16];
  69. }
  70. return _contentLable;
  71. }
  72. - (UIView *)lineView {
  73. if (!_lineView) {
  74. _lineView = [[UIView alloc]init];
  75. _lineView.backgroundColor = [UIColor colorWithHexString:@"#F9B37F"];
  76. _lineView.hidden = YES;
  77. }
  78. return _lineView;
  79. }
  80. - (void)refreshCellWithModel:(KBSignDetailModel *)detailModel andIndexPath:(NSIndexPath*)index {
  81. if (index.row != 0) {
  82. _lineView.hidden = NO;
  83. }
  84. [self.leftImageView sd_setImageWithURL:[NSURL URLWithString:detailModel.img] placeholderImage:nil];
  85. if (detailModel.postion) {
  86. NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:detailModel.content];
  87. [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:20.0f] range:NSMakeRange([detailModel.postion[@"pos"] intValue],[detailModel.postion[@"len"] intValue])];
  88. [self.contentLable setAttributedText:attrStr];
  89. }else {
  90. self.contentLable.text = detailModel.content;
  91. }
  92. [[self.rightBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
  93. [self.clickDelegate clickCellIndexPath:index];
  94. }];
  95. if (detailModel.type == 1) {
  96. self.rightBtn.backgroundColor = [UIColor colorWithHexString:@"#FF7E00"];
  97. self.rightBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  98. self.rightBtn.layer.borderColor = [UIColor colorWithHexString:@"#FF5266"].CGColor;
  99. [self.rightBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  100. self.rightBtn.enabled = YES;
  101. [self.rightBtn setTitle:detailModel.time_describe forState:UIControlStateNormal];
  102. }else if (detailModel.type == 0){
  103. self.rightBtn.backgroundColor = [UIColor clearColor];
  104. self.rightBtn.titleLabel.font = [UIFont systemFontOfSize:10];
  105. self.rightBtn.layer.borderColor = [UIColor colorWithHexString:@"#FF5266"].CGColor;
  106. [self.rightBtn setTitleColor:[UIColor colorWithHexString:@"#FF5266"] forState:UIControlStateNormal];
  107. self.rightBtn.enabled = NO;
  108. [self.rightBtn setTitle:detailModel.time_describe forState:UIControlStateNormal];
  109. }else {
  110. self.rightBtn.backgroundColor = [UIColor clearColor];
  111. self.rightBtn.titleLabel.font = [UIFont systemFontOfSize:10];
  112. self.rightBtn.layer.borderColor = [UIColor colorWithHexString:@"#F9041C"].CGColor;
  113. [self.rightBtn setTitleColor:[UIColor colorWithHexString:@"#F9041C"] forState:UIControlStateNormal];
  114. self.rightBtn.enabled = NO;
  115. [self.rightBtn setTitle:detailModel.time_describe forState:UIControlStateNormal];
  116. }
  117. }
  118. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  119. [super setSelected:selected animated:animated];
  120. // Configure the view for the selected state
  121. }
  122. @end