PeriodStuCell.m 4.4 KB

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