// // NeighbourCell.m // jiaPei // // Created by apple on 2017/6/30. // Copyright © 2017年 JCZ. All rights reserved. // #import "NeighbourCell.h" @implementation NeighbourCell - (void)awakeFromNib { [super awakeFromNib]; } -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { [self initWithWid:kSize.width height:125]; } return self; } -(instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self initWithWid:frame.size.width height:frame.size.height]; } return self; } - (void)initWithWid:(CGFloat)wid height:(CGFloat)hei { _titlelabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, wid - 40, 30)]; [_titlelabel setText:@"" Font:FontLarger TextColor:kTitleColor]; [self.contentView addSubview:_titlelabel]; _starBar = [[RatingBar alloc]initWithFrame:CGRectMake(0, 40, 150, 25) Flag:NO]; _starBar.enable = NO; _starBar.starNumber = 0; [self.contentView addSubview:_starBar]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(150, 40, wid - 200, 25)]; [label setText:@"" Font:Font17 TextColor:contentTextColor]; [self.contentView addSubview:label]; _readLabel = label; label = [[UILabel alloc] initWithFrame:CGRectMake(150, 40, wid - 200, 25)]; [label setText:@"" Font:Font17 TextColor:[UIColor magentaColor] Alignment:NSTextAlignmentRight]; // [self.contentView addSubview:label]; _priceLabel = label; label = [[UILabel alloc] initWithFrame:CGRectMake(20, 65, wid - 40, 25)]; [label setText:@"" Font:Font17 TextColor:contentTextColor]; [self.contentView addSubview:label]; _memoLabel = label; label = [[UILabel alloc] initWithFrame:CGRectMake(20, 90, wid - 40, 25)]; [label setText:@"" Font:Font17 TextColor:contentTextColor]; [self.contentView addSubview:label]; _adressLabel = label; } -(void)setDataDic:(NSDictionary *)dataDic { _dataDic = dataDic; _starBar.starNumber = [dataDic[@"STAR"] integerValue]; _titlelabel.text = [NSString stringWithFormat:@"%@(%@)",dataDic[@"SHORTNAME"],dataDic[@"TSP_NAME"]]; _readLabel.text = [NSString stringWithFormat:@"%@人关注",dataDic[@"WATCH"]]; _priceLabel.text = [NSString stringWithFormat:@"%@元",dataDic[@"PRICE"]]; _memoLabel.text = [NSString stringWithFormat:@"备注:%@",dataDic[@"TSP_MEMO"]]; NSString *distenceString = @""; float distence = [dataDic[@"DIS"] floatValue]; if (distence < 1000) { distenceString = [NSString stringWithFormat:@"%.0f米",distence]; }else { distenceString = [NSString stringWithFormat:@"%.1f公里",distence/1000.0]; } _adressLabel.text = [NSString stringWithFormat:@"%@ %@",dataDic[@"TSP_ADDRESS"],distenceString]; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; } @end