detailTableViewCell.m 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // detailTableViewCell.m
  3. // BuguLive
  4. //
  5. // Created by lxt2016 on 16/11/29.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. //
  8. #import "detailTableViewCell.h"
  9. @implementation detailTableViewCell
  10. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  11. {
  12. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
  13. {
  14. self.detailLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, kScreenW-10, 45)];
  15. self.detailLabel.numberOfLines = 0;
  16. self.detailLabel.textColor = kAppGrayColor1;
  17. self.detailLabel.font = [UIFont systemFontOfSize:14];
  18. self.detailLabel.text = ASLocalizedString(@"拍品详情");
  19. [self addSubview:self.detailLabel];
  20. // self.lineView = [[UIView alloc]init];
  21. // self.lineView.backgroundColor = kAppSpaceColor4;
  22. // [self addSubview:self.lineView];
  23. }
  24. return self ;
  25. }
  26. - (CGFloat)setCellWithString:(NSString *)string
  27. {
  28. NSString *detailString = [NSString stringWithFormat:ASLocalizedString(@"拍品详情:%@"),string];
  29. NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:detailString];
  30. [attr setAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14.0]} range:NSMakeRange(0, detailString.length)];
  31. //约会地点
  32. NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:14]};
  33. // 参数1代表文字自适应的范围,参数2代表文字自适应的方式(前三种),参数3代表文字在自适应过程中以多大的字体作为依据
  34. CGFloat height = [detailString boundingRectWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width - 10, 10000000) options:NSStringDrawingTruncatesLastVisibleLine |NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attributes context:nil].size.height;
  35. // self.detailLabel.frame = CGRectMake(10, 0, kScreenW-10, height+10);
  36. self.detailLabel.attributedText = attr;
  37. // self.lineView.frame = CGRectMake(0, height+10, kScreenW, 1);
  38. // [self addSubview:self.lineView];
  39. return height+10;
  40. }
  41. @end