《省钱达人》与《猎豆优选》UI相同版。域名tbk

DRNativeShopCarHeader.m 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // DRNativeShopCarHeader.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/12/10.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRNativeShopCarHeader.h"
  9. @interface DRNativeShopCarHeader ()
  10. @property (nonatomic, strong) UILabel *titleLb;
  11. @property (nonatomic, strong) UIImageView *imgView;
  12. @end
  13. @implementation DRNativeShopCarHeader
  14. - (instancetype)initWithFrame:(CGRect)frame
  15. {
  16. self = [super initWithFrame:frame];
  17. if (self) {
  18. [self initSubViews];
  19. }
  20. return self;
  21. }
  22. - (void)initSubViews {
  23. UIView *bg = [[UIView alloc] initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH-20, 35)];
  24. [self addSubview:bg];
  25. // 设置圆角
  26. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:bg.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(5, 5)];
  27. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  28. maskLayer.frame = bg.bounds;
  29. maskLayer.path = maskPath.CGPath;
  30. bg.layer.mask = maskLayer;
  31. bg.backgroundColor = [UIColor whiteColor];
  32. self.imgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, 16, 16)];
  33. [bg addSubview:self.imgView];
  34. self.imgView.centerY = bg.height/2;
  35. UILabel *nick = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 20)];
  36. nick.font = [UIFont systemFontOfSize:13];
  37. nick.centerY = bg.height/2;
  38. [bg addSubview:nick];
  39. nick.left = self.imgView.right+5;
  40. self.titleLb = nick;
  41. }
  42. - (void)setModel:(DRChildGoodModel *)model {
  43. _model = model;
  44. NSString *imgName = [model.shop_type boolValue]?@"cl-tm":@"taobao_shop";
  45. self.imgView.image = [UIImage imageNamed:imgName];
  46. self.titleLb.text = model.nick;
  47. }
  48. @end