123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- //
- // 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
|