// // YOUPAILZLabelCollectionCell.m // VQU // // Created by CY on 2021/7/15. // Copyright © 2021 leo. All rights reserved. // #import "YOUPAILZLabelCollectionCell.h" @interface YOUPAILZLabelCollectionCell () @property (nonatomic,weak) UIButton *youpaiptitleBtn; @end @implementation YOUPAILZLabelCollectionCell - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self youpaifinitUI]; } return self; } - (void)youpaifinitUI{ self.contentView.layer.cornerRadius = self.contentView.size.height/2.0; self.contentView.layer.masksToBounds = YES; UIButton *titleBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [titleBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; titleBtn.titleLabel.font = LCFont12; titleBtn.backgroundColor = HexColorFromRGB(0x4F4B5B); [self.contentView addSubview:titleBtn]; self.youpaiptitleBtn = titleBtn; titleBtn.userInteractionEnabled = NO; [titleBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.top.bottom.right.offset(0.0f); }]; } - (void)youpaifreloadWithModel:(YOUPAIZYLabelModel *)model{ if (model.youpaipnum>0) { [self.youpaiptitleBtn setTitle:[NSString stringWithFormat:@"%@",model.youpaipname] forState:UIControlStateNormal]; }else{ [self.youpaiptitleBtn setTitle:[NSString stringWithFormat:@"%@",model.youpaipname] forState:UIControlStateNormal]; } if (model.youpaipisSelect) { NSString *shallow = [NSString stringWithFormat:@"%@",model.youpaipstart_color]; NSString *deep = [NSString stringWithFormat:@"%@",model.youpaipover_color]; self.youpaiptitleBtn.backgroundColor = [UIColor clearColor]; [self.youpaiptitleBtn setBackgroundImage:[LCTools ColorImage:self.contentView.size FromColors:@[kColors(shallow),kColors(deep)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal]; }else{ self.youpaiptitleBtn.backgroundColor = HexColorFromRGB(0x4F4B5B); [self.youpaiptitleBtn setBackgroundImage:nil forState:UIControlStateNormal]; } } @end