YOUPAILZLabelCollectionCell.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // YOUPAILZLabelCollectionCell.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/7/15.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAILZLabelCollectionCell.h"
  9. @interface YOUPAILZLabelCollectionCell ()
  10. @property (nonatomic,weak) UIButton *youpaiptitleBtn;
  11. @end
  12. @implementation YOUPAILZLabelCollectionCell
  13. - (instancetype)initWithFrame:(CGRect)frame {
  14. self = [super initWithFrame:frame];
  15. if (self) {
  16. [self youpaifinitUI];
  17. }
  18. return self;
  19. }
  20. - (void)youpaifinitUI{
  21. self.contentView.layer.cornerRadius = self.contentView.size.height/2.0;
  22. self.contentView.layer.masksToBounds = YES;
  23. UIButton *titleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  24. [titleBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  25. titleBtn.titleLabel.font = LCFont12;
  26. titleBtn.backgroundColor = HexColorFromRGB(0x4F4B5B);
  27. [self.contentView addSubview:titleBtn];
  28. self.youpaiptitleBtn = titleBtn;
  29. titleBtn.userInteractionEnabled = NO;
  30. [titleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.left.top.bottom.right.offset(0.0f);
  32. }];
  33. }
  34. - (void)youpaifreloadWithModel:(YOUPAIZYLabelModel *)model{
  35. if (model.youpaipnum>0) {
  36. [self.youpaiptitleBtn setTitle:[NSString stringWithFormat:@"%@",model.youpaipname] forState:UIControlStateNormal];
  37. }else{
  38. [self.youpaiptitleBtn setTitle:[NSString stringWithFormat:@"%@",model.youpaipname] forState:UIControlStateNormal];
  39. }
  40. if (model.youpaipisSelect) {
  41. NSString *shallow = [NSString stringWithFormat:@"%@",model.youpaipstart_color];
  42. NSString *deep = [NSString stringWithFormat:@"%@",model.youpaipover_color];
  43. self.youpaiptitleBtn.backgroundColor = [UIColor clearColor];
  44. [self.youpaiptitleBtn setBackgroundImage:[LCTools ColorImage:self.contentView.size FromColors:@[kColors(shallow),kColors(deep)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal];
  45. }else{
  46. self.youpaiptitleBtn.backgroundColor = HexColorFromRGB(0x4F4B5B);
  47. [self.youpaiptitleBtn setBackgroundImage:nil forState:UIControlStateNormal];
  48. }
  49. }
  50. @end