// // PeriodStuCell.m // JSJPCoach // // Created by apple on 2017/3/24. // Copyright © 2017年 Danson. All rights reserved. // #import "PeriodStuCell.h" @implementation PeriodStuCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { self.backgroundColor = [UIColor clearColor]; self.selectionStyle = UITableViewCellSelectionStyleNone; self.headImgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 12, 50, 56)]; [self.headImgView borderCornorRadios:5]; [self.contentView addSubview:self.headImgView]; self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(70, 10, kSize.width - 80, 30)]; [self.nameLabel setText:@"" Font:Font17 TextColor:newTitleColor]; [self.contentView addSubview:self.nameLabel]; self.telLabel = [[UILabel alloc] initWithFrame:CGRectMake(70, 40, kSize.width - 80, 30)]; [self.nameLabel setText:@"" Font:Font17 TextColor:canClickColor]; [self.contentView addSubview:self.telLabel]; UIButton *telBtn = [[UIButton alloc] initWithFrame:CGRectMake(70, 30, kSize.width - 70, 50)]; [telBtn target:self Tag:1]; [self.contentView addSubview:telBtn]; } return self; } -(instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor clearColor]; self.selectionStyle = UITableViewCellSelectionStyleNone; self.headImgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 12, 50, 56)]; [self.headImgView borderCornorRadios:5]; [self.contentView addSubview:self.headImgView]; self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(70, 10, kSize.width - 80, 30)]; [self.nameLabel setText:@"" Font:Font17 TextColor:newTitleColor]; [self.contentView addSubview:self.nameLabel]; self.telLabel = [[UILabel alloc] initWithFrame:CGRectMake(70, 40, kSize.width - 80, 30)]; [self.telLabel setText:@"" Font:Font17 TextColor:newTitleColor]; [self.contentView addSubview:self.telLabel]; UIButton *telBtn = [[UIButton alloc] initWithFrame:CGRectMake(70, 30, kSize.width - 70, 50)]; [telBtn target:self Tag:1]; [self.contentView addSubview:telBtn]; } return self; } -(void)setDataDic:(NSDictionary *)dataDic { _dataDic = dataDic; NSString *imgpath = dataDic[@"TSO_PHOTO_PATH"]; if (imgpath.length < 1) { imgpath = @""; } [self.headImgView sd_setImageWithURL:[NSURL URLWithString:imgpath] placeholderImage:[UIImage imageNamed:@"noHeadImg.png"]]; self.nameLabel.text = dataDic[@"TSO_NAME"]; if ([dataDic[@"TSO_PHONE"] length] > 0) { NSMutableAttributedString *abs = [[NSMutableAttributedString alloc]initWithString:dataDic[@"TSO_PHONE"]]; [abs beginEditing]; //字体大小 [abs addAttribute:NSFontAttributeName value:[UIFont scaleSize:Font17] range:NSMakeRange(0, [dataDic[@"TSO_PHONE"] length])]; //字体颜色 [abs addAttribute:NSForegroundColorAttributeName value:canClickColor range:NSMakeRange(0, [dataDic[@"TSO_PHONE"] length])]; //下划线 [abs addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:NSMakeRange(0, [dataDic[@"TSO_PHONE"] length])]; self.telLabel.attributedText = abs; }else{ self.telLabel.text = dataDic[@"TSO_PHONE"]; } } -(void)setImgPath:(NSString *)imgPath { _imgPath = imgPath; if (imgPath.length < 1) { imgPath = @""; } [self.headImgView sd_setImageWithURL:[NSURL URLWithString:imgPath] placeholderImage:[UIImage imageNamed:@"noHeadImg.png"]]; } - (void)btnClick:(UIButton *)sender { //拨打电话 NSString *tel = self.telLabel.text; if (tel && ![tel isEqualToString:@""]) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",tel]]]; } } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end