SubTitleCell.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // SubTitleCell.m
  3. // jiaPei
  4. //
  5. // Created by apple on 15/11/27.
  6. // Copyright (c) 2015年 JCZ. All rights reserved.
  7. //
  8. #import "SubTitleCell.h"
  9. @implementation SubTitleCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. // Initialization code
  13. }
  14. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  15. [super setSelected:selected animated:animated];
  16. // Configure the view for the selected state
  17. }
  18. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  19. {
  20. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  21. if (self) {
  22. // cfiView = [[CFIView alloc] init];
  23. self.backgroundColor = backGroundColor;
  24. // [self.contentView addSubview:cfiView];
  25. [self.imageView setImage:[UIImage imageNamed:@"subject2_standart_icon.png"]];
  26. [self.textLabel setTextColor:kTitleColor];
  27. [self.detailTextLabel setTextColor:contentTextColor];
  28. }
  29. return self;
  30. }
  31. -(void)setIndex:(NSInteger)index{
  32. _index = index;
  33. // [cfiView setIndex:index];
  34. }
  35. /**每次cell重用时,这里都会调用一次。
  36. 切记不要再这里创建视图。
  37. 圈圈固定宽高为40.
  38. 标题和子标题各占一半。
  39. */
  40. -(void)layoutSubviews
  41. {
  42. [super layoutSubviews];
  43. CGFloat x,y,w,h;
  44. w = h = self.height * .4;
  45. x = 20;
  46. y = (self.height - h)/2.0;
  47. [self.imageView setFrame:CGRectMake(x, y, w, h)];
  48. x = x*2 + w;
  49. y = 0;
  50. w = self.width - x;
  51. h = self.height ;
  52. [self.textLabel setFrame:CGRectMake(x, y, w, h)];
  53. // y = self.height * .4;
  54. [self.detailTextLabel setFrame:CGRectMake(x, y, w, h)];
  55. }
  56. @end