SevenSectionTableViewCell.m 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // SevenSectionTableViewCell.m
  3. // BuguLive
  4. //
  5. // Created by fanwe2014 on 16/8/5.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. #import "SevenSectionTableViewCell.h"
  8. @implementation SevenSectionTableViewCell
  9. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  10. {
  11. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  12. if (self)
  13. {
  14. self.titleLabel = [[UILabel alloc]init];
  15. self.titleLabel.textColor = kAppGrayColor5;
  16. self.titleLabel.numberOfLines = 0;
  17. [self.titleLabel sizeToFit];
  18. [self addSubview:self.titleLabel];
  19. }
  20. return self;
  21. }
  22. - (CGFloat)setCellWithString:(NSString *)string
  23. {
  24. NSString *nameString = [NSString stringWithFormat:ASLocalizedString(@"竞拍名称:%@"),string];;
  25. NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:nameString];
  26. [attr setAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:17.0]} range:NSMakeRange(0,nameString.length)];
  27. NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:17]};
  28. CGFloat height = [nameString boundingRectWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width - 10, 10000000) options:NSStringDrawingTruncatesLastVisibleLine |NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attributes context:nil].size.height;
  29. NSLog(@"height==%f",height);
  30. // CGFloat height =[nameString sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17]}].height;
  31. self.titleLabel.frame = CGRectMake(10, 0, kScreenW-10, height+15);
  32. self.titleLabel.attributedText = attr;
  33. return height+15;
  34. }
  35. @end