EmployeeTableViewCell.m 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //
  2. // EmployeeTableViewCell.m
  3. // shiku_im
  4. //
  5. // Created by 1 on 17/5/18.
  6. // Copyright © 2017年 Reese. All rights reserved.
  7. //
  8. #import "EmployeeTableViewCell.h"
  9. @implementation EmployeeTableViewCell
  10. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  11. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  12. if (self) {
  13. self.selectedBackgroundView = [UIView new];
  14. self.selectedBackgroundView.backgroundColor = [UIColor clearColor];
  15. [self customUI];
  16. }
  17. return self;
  18. }
  19. -(void)customUI{
  20. self.backgroundColor = [UIColor whiteColor];
  21. _headImageView = [[UIImageView alloc]init];
  22. _headImageView.frame = CGRectMake(10,12,36,36);
  23. _headImageView.layer.cornerRadius = _headImageView.frame.size.width/2;
  24. _headImageView.layer.masksToBounds = YES;
  25. _headImageView.layer.borderColor = [UIColor darkGrayColor].CGColor;
  26. [self.contentView addSubview:self.headImageView];
  27. _customTitleLabel = [UIFactory createLabelWith:CGRectMake(CGRectGetMaxX(_headImageView.frame)+16, 12, 100, 15) text:@"" font:g_UIFactory.font15 textColor:[UIColor blackColor] backgroundColor:nil];
  28. _customTitleLabel.textAlignment = NSTextAlignmentLeft;
  29. _customTitleLabel.textColor = [UIColor blackColor];
  30. [self.contentView addSubview:_customTitleLabel];
  31. _positionLabel = [UIFactory createLabelWith:CGRectMake(CGRectGetMaxX(_headImageView.frame)+16, CGRectGetMaxY(_headImageView.frame)-13, 100, 13) text:@"" font:g_factory.font13 textColor:THEMECOLOR backgroundColor:nil];
  32. // _positionLabel.layer.backgroundColor = [UIColor orangeColor].CGColor;
  33. // _positionLabel.layer.cornerRadius = 5;
  34. // _positionLabel.textAlignment = NSTextAlignmentCenter;
  35. [self.contentView addSubview:_positionLabel];
  36. _line = [[UIView alloc] initWithFrame:CGRectMake(15, 60-LINE_WH, JX_SCREEN_WIDTH-15, LINE_WH)];
  37. _line.backgroundColor = THE_LINE_COLOR;
  38. [self.contentView addSubview:_line];
  39. }
  40. -(void)layoutSubviews{
  41. [super layoutSubviews];
  42. [self layoutIfNeeded];
  43. }
  44. - (void)prepareForReuse
  45. {
  46. [super prepareForReuse];
  47. }
  48. //- (void)willTransitionToState:(UITableViewCellStateMask)state{
  49. //
  50. //}
  51. - (void)setupWithData:(EmployeObject *)dataObj level:(NSInteger)level
  52. {
  53. self.customTitleLabel.text = dataObj.nickName;
  54. self.positionLabel.text = dataObj.position;
  55. [g_server getHeadImageSmall:dataObj.userId userName:dataObj.nickName imageView:_headImageView];
  56. self.employObject = dataObj;
  57. CGFloat left = 11 + 20 * level;
  58. // CGRect titleFrame = self.customTitleLabel.frame;
  59. CGRect headFrame = self.headImageView.frame;
  60. headFrame.origin.x = left;
  61. self.headImageView.frame = headFrame;
  62. self.customTitleLabel.frame = CGRectMake(CGRectGetMaxX(_headImageView.frame)+16, 12, 100, 15);
  63. self.positionLabel.frame = CGRectMake(CGRectGetMaxX(_headImageView.frame)+16, CGRectGetMaxY(_headImageView.frame)-13, 100, 13);
  64. self.line.frame = CGRectMake(left, self.line.frame.origin.y, JX_SCREEN_WIDTH-left, self.line.frame.size.height);
  65. // CGSize nameSize =[dataObj.nickName sizeWithAttributes:@{NSFontAttributeName:self.customTitleLabel.font}];
  66. // titleFrame.origin.x = left + CGRectGetWidth(_headImageView.frame) + 4;
  67. // titleFrame.size = nameSize;
  68. // self.customTitleLabel.frame = titleFrame;
  69. // self.customTitleLabel.center = CGPointMake(_customTitleLabel.center.x, self.headImageView.center.y);
  70. // CGSize positionSize =[dataObj.position sizeWithAttributes:@{NSFontAttributeName:self.positionLabel.font}];
  71. // if (positionSize.width >150)
  72. // positionSize.width = 150;
  73. // self.positionLabel.frame = CGRectMake(CGRectGetMaxX(self.customTitleLabel.frame)+2, CGRectGetMinY(self.customTitleLabel.frame), positionSize.width+4, positionSize.height);
  74. }
  75. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  76. [super setSelected:selected animated:animated];
  77. // Configure the view for the selected state
  78. }
  79. @end