SubTitleCell.m 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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.contentView addSubview:cfiView];
  24. [self.imageView setImage:[UIImage imageNamed:@"subject2_standart_icon.png"]];
  25. [self.textLabel setTextColor:kTitleColor];
  26. [self.detailTextLabel setTextColor:contentTextColor];
  27. }
  28. return self;
  29. }
  30. -(void)setIndex:(NSInteger)index{
  31. _index = index;
  32. // [cfiView setIndex:index];
  33. }
  34. /**每次cell重用时,这里都会调用一次。
  35. 切记不要再这里创建视图。
  36. 圈圈固定宽高为40.
  37. 标题和子标题各占一半。
  38. */
  39. -(void)layoutSubviews
  40. {
  41. [super layoutSubviews];
  42. CGFloat x,y,w,h;
  43. w = h = self.height * .4;
  44. x = 20;
  45. y = (self.height - h)/2.0;
  46. [self.imageView setFrame:CGRectMake(x, y, w, h)];
  47. x = x*2 + w;
  48. y = 0;
  49. w = self.width - x;
  50. h = self.height ;
  51. [self.textLabel setFrame:CGRectMake(x, y, w, h)];
  52. // y = self.height * .4;
  53. [self.detailTextLabel setFrame:CGRectMake(x, y, w, h)];
  54. }
  55. @end