// // KBNativeShopCarHeader.m // YouHuiProject // // Created by 小花 on 2018/11/6. // Copyright © 2018年 kuxuan. All rights reserved. // #import "KBNativeShopCarHeader.h" @interface KBNativeShopCarHeader () @end @implementation KBNativeShopCarHeader - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor homeRedColor]; [self initSubViews]; } return self; } - (void)initSubViews { NSArray *titles = @[@"发现宝贝",@"隐藏优惠券",@"可省钱"]; CGFloat width = (SCREEN_WIDTH)/3; for (int i = 0; i < titles.count; i++) { UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(width*i, 5, width, 18)]; titleLabel.textAlignment = NSTextAlignmentCenter; titleLabel.textColor = [UIColor whiteColor]; titleLabel.font = [UIFont systemFontOfSize:13]; titleLabel.text = titles[i]; [self addSubview:titleLabel]; UILabel *detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH/3, 22)]; detailLabel.y = titleLabel.bottom; detailLabel.centerX = titleLabel.centerX; detailLabel.textColor = [UIColor whiteColor]; detailLabel.textAlignment = NSTextAlignmentCenter; detailLabel.font = [UIFont boldSystemFontOfSize:15]; detailLabel.tag = 1000+i; [self addSubview:detailLabel]; } } - (void)setDataWithDic:(id)dict { NSString *count = [NSString stringWithFormat:@"%@件",dict[@"allGoodsNum"]]; NSString *allCoupon = [NSString stringWithFormat:@"%@张",dict[@"allCouponsGoods"]]; NSString *totalCouponMoney = [NSString stringWithFormat:@"%@元",dict[@"totalCouponMoney"]]; NSArray *titles = @[count, allCoupon, totalCouponMoney]; for (int i = 0; i < titles.count; i++) { UILabel *label = [self viewWithTag:1000+i]; label.text = titles[i]; } } @end