口袋优选

KBNativeShopCarHeader.m 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // KBNativeShopCarHeader.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/11/6.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBNativeShopCarHeader.h"
  9. @interface KBNativeShopCarHeader ()
  10. @end
  11. @implementation KBNativeShopCarHeader
  12. - (instancetype)initWithFrame:(CGRect)frame
  13. {
  14. self = [super initWithFrame:frame];
  15. if (self) {
  16. self.backgroundColor = [UIColor homeRedColor];
  17. [self initSubViews];
  18. }
  19. return self;
  20. }
  21. - (void)initSubViews {
  22. NSArray *titles = @[@"发现宝贝",@"隐藏优惠券",@"可省钱"];
  23. CGFloat width = (SCREEN_WIDTH)/3;
  24. for (int i = 0; i < titles.count; i++) {
  25. UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(width*i, 5, width, 18)];
  26. titleLabel.textAlignment = NSTextAlignmentCenter;
  27. titleLabel.textColor = [UIColor whiteColor];
  28. titleLabel.font = [UIFont systemFontOfSize:13];
  29. titleLabel.text = titles[i];
  30. [self addSubview:titleLabel];
  31. UILabel *detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH/3, 22)];
  32. detailLabel.y = titleLabel.bottom;
  33. detailLabel.centerX = titleLabel.centerX;
  34. detailLabel.textColor = [UIColor whiteColor];
  35. detailLabel.textAlignment = NSTextAlignmentCenter;
  36. detailLabel.font = [UIFont boldSystemFontOfSize:15];
  37. detailLabel.tag = 1000+i;
  38. [self addSubview:detailLabel];
  39. }
  40. }
  41. - (void)setDataWithDic:(id)dict {
  42. NSString *count = [NSString stringWithFormat:@"%@件",dict[@"allGoodsNum"]];
  43. NSString *allCoupon = [NSString stringWithFormat:@"%@张",dict[@"allCouponsGoods"]];
  44. NSString *totalCouponMoney = [NSString stringWithFormat:@"%@元",dict[@"totalCouponMoney"]];
  45. NSArray *titles = @[count, allCoupon, totalCouponMoney];
  46. for (int i = 0; i < titles.count; i++) {
  47. UILabel *label = [self viewWithTag:1000+i];
  48. label.text = titles[i];
  49. }
  50. }
  51. @end