// // DRNativeShopCarHeader.m // YouHuiProject // // Created by 小花 on 2018/12/10. // Copyright © 2018年 kuxuan. All rights reserved. // #import "DRNativeShopCarHeader.h" @interface DRNativeShopCarHeader () @property (nonatomic, strong) UILabel *titleLb; @property (nonatomic, strong) UIImageView *imgView; @end @implementation DRNativeShopCarHeader - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self initSubViews]; } return self; } - (void)initSubViews { UIView *bg = [[UIView alloc] initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH-20, 35)]; [self addSubview:bg]; // 设置圆角 UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:bg.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(5, 5)]; CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; maskLayer.frame = bg.bounds; maskLayer.path = maskPath.CGPath; bg.layer.mask = maskLayer; bg.backgroundColor = [UIColor whiteColor]; self.imgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, 16, 16)]; [bg addSubview:self.imgView]; self.imgView.centerY = bg.height/2; UILabel *nick = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 20)]; nick.font = [UIFont systemFontOfSize:13]; nick.centerY = bg.height/2; [bg addSubview:nick]; nick.left = self.imgView.right+5; self.titleLb = nick; } - (void)setModel:(DRChildGoodModel *)model { _model = model; NSString *imgName = [model.shop_type boolValue]?@"cl-tm":@"taobao_shop"; self.imgView.image = [UIImage imageNamed:imgName]; self.titleLb.text = model.nick; } @end