PeriodStuCell.m 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //
  2. // PeriodStuCell.m
  3. // JSJPCoach
  4. //
  5. // Created by apple on 2017/3/24.
  6. // Copyright © 2017年 Danson. All rights reserved.
  7. //
  8. #import "PeriodStuCell.h"
  9. #import "UIImageView+WebCache.h"
  10. @implementation PeriodStuCell
  11. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  12. {
  13. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
  14. {
  15. self.backgroundColor = [UIColor clearColor];
  16. self.selectionStyle = UITableViewCellSelectionStyleNone;
  17. self.headImgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 12, 50, 56)];
  18. [self.headImgView borderCornorRadios:5];
  19. [self.contentView addSubview:self.headImgView];
  20. self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(70, 10, kSize.width - 80, 30)];
  21. [self.nameLabel setText:@"" Font:Font17 TextColor:newTitleColor];
  22. [self.contentView addSubview:self.nameLabel];
  23. self.telLabel = [[UILabel alloc] initWithFrame:CGRectMake(70, 40, kSize.width - 80, 30)];
  24. [self.nameLabel setText:@"" Font:Font17 TextColor:canClickColor];
  25. [self.contentView addSubview:self.telLabel];
  26. UIButton *telBtn = [[UIButton alloc] initWithFrame:CGRectMake(70, 30, kSize.width - 70, 50)];
  27. [telBtn target:self Tag:1];
  28. [self.contentView addSubview:telBtn];
  29. }
  30. return self;
  31. }
  32. -(instancetype)initWithFrame:(CGRect)frame
  33. {
  34. self = [super initWithFrame:frame];
  35. if (self) {
  36. self.backgroundColor = [UIColor clearColor];
  37. self.selectionStyle = UITableViewCellSelectionStyleNone;
  38. self.headImgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 12, 50, 56)];
  39. [self.headImgView borderCornorRadios:5];
  40. [self.contentView addSubview:self.headImgView];
  41. self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(70, 10, kSize.width - 80, 30)];
  42. [self.nameLabel setText:@"" Font:Font17 TextColor:newTitleColor];
  43. [self.contentView addSubview:self.nameLabel];
  44. self.telLabel = [[UILabel alloc] initWithFrame:CGRectMake(70, 40, kSize.width - 80, 30)];
  45. [self.telLabel setText:@"" Font:Font17 TextColor:newTitleColor];
  46. [self.contentView addSubview:self.telLabel];
  47. UIButton *telBtn = [[UIButton alloc] initWithFrame:CGRectMake(70, 30, kSize.width - 70, 50)];
  48. [telBtn target:self Tag:1];
  49. [self.contentView addSubview:telBtn];
  50. }
  51. return self;
  52. }
  53. -(void)setDataDic:(NSDictionary *)dataDic
  54. {
  55. _dataDic = dataDic;
  56. NSString *imgpath = dataDic[@"PHOTO"];
  57. if (imgpath.length < 1) {
  58. imgpath = @"";
  59. }
  60. [self.headImgView sd_setImageWithURL:[NSURL URLWithString:imgpath] placeholderImage:[UIImage imageNamed:@"noHeadImg.png"]];
  61. // self.nameLabel.text = dataDic[@"RI_USER_NAME"];
  62. if ([dataDic[@"RI_USER_TEL"] length] > 0) {
  63. NSMutableAttributedString *abs = [[NSMutableAttributedString alloc]initWithString:dataDic[@"RI_USER_TEL"]];
  64. [abs beginEditing];
  65. //字体大小
  66. [abs addAttribute:NSFontAttributeName
  67. value:[UIFont scaleSize:Font17]
  68. range:NSMakeRange(0, [dataDic[@"RI_USER_TEL"] length])];
  69. //字体颜色
  70. [abs addAttribute:NSForegroundColorAttributeName
  71. value:canClickColor
  72. range:NSMakeRange(0, [dataDic[@"RI_USER_TEL"] length])];
  73. //下划线
  74. [abs addAttribute:NSUnderlineStyleAttributeName
  75. value:@(NSUnderlineStyleSingle)
  76. range:NSMakeRange(0, [dataDic[@"RI_USER_TEL"] length])];
  77. self.telLabel.attributedText = abs;
  78. }else{
  79. self.telLabel.text = dataDic[@"RI_USER_TEL"];
  80. }
  81. }
  82. -(void)setImgPath:(NSString *)imgPath
  83. {
  84. _imgPath = imgPath;
  85. if (imgPath.length < 1) {
  86. imgPath = @"";
  87. }
  88. [self.headImgView sd_setImageWithURL:[NSURL URLWithString:imgPath] placeholderImage:[UIImage imageNamed:@"noHeadImg.png"]];
  89. }
  90. - (void)btnClick:(UIButton *)sender
  91. {
  92. //拨打电话
  93. NSString *tel = self.telLabel.text;
  94. if (tel && ![tel isEqualToString:@""]) {
  95. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",tel]]];
  96. }
  97. }
  98. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  99. [super setSelected:selected animated:animated];
  100. // Configure the view for the selected state
  101. }
  102. @end