NeighbourCell.m 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //
  2. // NeighbourCell.m
  3. // jiaPei
  4. //
  5. // Created by apple on 2017/6/30.
  6. // Copyright © 2017年 JCZ. All rights reserved.
  7. //
  8. #import "NeighbourCell.h"
  9. @implementation NeighbourCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. }
  13. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  14. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  15. if (self) {
  16. [self initWithWid:kSize.width height:125];
  17. }
  18. return self;
  19. }
  20. -(instancetype)initWithFrame:(CGRect)frame {
  21. self = [super initWithFrame:frame];
  22. if (self) {
  23. [self initWithWid:frame.size.width height:frame.size.height];
  24. }
  25. return self;
  26. }
  27. - (void)initWithWid:(CGFloat)wid height:(CGFloat)hei {
  28. _titlelabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, wid - 40, 30)];
  29. [_titlelabel setText:@"" Font:FontLarger TextColor:kTitleColor];
  30. [self.contentView addSubview:_titlelabel];
  31. _starBar = [[RatingBar alloc]initWithFrame:CGRectMake(0, 40, 150, 25) Flag:NO];
  32. _starBar.enable = NO;
  33. _starBar.starNumber = 0;
  34. [self.contentView addSubview:_starBar];
  35. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(150, 40, wid - 200, 25)];
  36. [label setText:@"" Font:Font17 TextColor:contentTextColor];
  37. [self.contentView addSubview:label];
  38. _readLabel = label;
  39. label = [[UILabel alloc] initWithFrame:CGRectMake(150, 40, wid - 200, 25)];
  40. [label setText:@"" Font:Font17 TextColor:[UIColor magentaColor] Alignment:NSTextAlignmentRight];
  41. // [self.contentView addSubview:label];
  42. _priceLabel = label;
  43. label = [[UILabel alloc] initWithFrame:CGRectMake(20, 65, wid - 40, 25)];
  44. [label setText:@"" Font:Font17 TextColor:contentTextColor];
  45. [self.contentView addSubview:label];
  46. _memoLabel = label;
  47. label = [[UILabel alloc] initWithFrame:CGRectMake(20, 90, wid - 40, 25)];
  48. [label setText:@"" Font:Font17 TextColor:contentTextColor];
  49. [self.contentView addSubview:label];
  50. _adressLabel = label;
  51. }
  52. -(void)setDataDic:(NSDictionary *)dataDic {
  53. _dataDic = dataDic;
  54. _starBar.starNumber = [dataDic[@"STAR"] integerValue];
  55. _titlelabel.text = [NSString stringWithFormat:@"%@(%@)",dataDic[@"SHORTNAME"],dataDic[@"TSP_NAME"]];
  56. _readLabel.text = [NSString stringWithFormat:@"%@人关注",dataDic[@"WATCH"]];
  57. _priceLabel.text = [NSString stringWithFormat:@"%@元",dataDic[@"PRICE"]];
  58. _memoLabel.text = [NSString stringWithFormat:@"备注:%@",dataDic[@"TSP_MEMO"]];
  59. NSString *distenceString = @"";
  60. float distence = [dataDic[@"DIS"] floatValue];
  61. if (distence < 1000) {
  62. distenceString = [NSString stringWithFormat:@"%.0f米",distence];
  63. }else {
  64. distenceString = [NSString stringWithFormat:@"%.1f公里",distence/1000.0];
  65. }
  66. _adressLabel.text = [NSString stringWithFormat:@"%@ %@",dataDic[@"TSP_ADDRESS"],distenceString];
  67. }
  68. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  69. [super setSelected:selected animated:animated];
  70. }
  71. @end