ExplainCell.m 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // ExplainCell.m
  3. // BuguLive
  4. //
  5. // Created by 王珂 on 17/4/27.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "ExplainCell.h"
  9. @implementation ExplainCell
  10. + (instancetype)cellWithTableView:(UITableView *)tableView
  11. {
  12. static NSString *ID = @"ExplainCell";
  13. ExplainCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  14. if (!cell)
  15. {
  16. cell = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] lastObject];
  17. }
  18. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  19. return cell;
  20. }
  21. - (void)awakeFromNib
  22. {
  23. [super awakeFromNib];
  24. self.contentView.backgroundColor = [UIColor whiteColor];
  25. self.titleLabel.textColor = kAppGrayColor1;
  26. self.explainLabel.textColor = [UIColor colorWithHexString:@"#666666"];
  27. self.explainLabel.hidden =
  28. self.titleLabel.hidden = YES;
  29. // kAppGrayColor2;
  30. // self.explainLabel.preferredMaxLayoutWidth = kScreenW-20;
  31. }
  32. -(void)setModel:(BingdingStateModel *)model
  33. {
  34. _model = model;
  35. NSString * explainStr;
  36. if (model.refund_explain && model.refund_explain.count>0)
  37. {
  38. explainStr = [NSString stringWithFormat:ASLocalizedString(@"提现说明:%@"),[model.refund_explain componentsJoinedByString:@"\r\n"]];
  39. }
  40. else
  41. {
  42. explainStr = @"";
  43. }
  44. if (kIsCheckingVersion()) {
  45. explainStr = @"";
  46. }
  47. NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:explainStr];
  48. NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init];
  49. [attrStr addAttribute:NSFontAttributeName
  50. value:[UIFont systemFontOfSize:15.0f]
  51. range:NSMakeRange(0, [explainStr length])];
  52. //行间距
  53. paragraph.lineSpacing = 5;
  54. //段落间距
  55. paragraph.paragraphSpacing = 5;
  56. //对齐方式
  57. paragraph.alignment = NSTextAlignmentLeft;
  58. //指定段落开始的缩进像素
  59. paragraph.firstLineHeadIndent = 0;
  60. //调整全部文字的缩进像素
  61. paragraph.headIndent = 5;
  62. [attrStr addAttribute:NSParagraphStyleAttributeName
  63. value:paragraph
  64. range:NSMakeRange(0, [explainStr length])];
  65. self.explainLabel.attributedText = attrStr;
  66. [self.explainLabel sizeToFit];
  67. [self layoutIfNeeded];
  68. model.explainCellHeight = CGRectGetMaxY(self.explainLabel.frame)+10;
  69. }
  70. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  71. [super setSelected:selected animated:animated];
  72. // Configure the view for the selected state
  73. }
  74. @end