// // YOUPAILZVipSetterCell.m // VQU // // Created by CY on 2021/8/21. // Copyright © 2021 MS. All rights reserved. // #import "YOUPAILZVipSetterCell.h" @interface YOUPAILZVipSetterCell () @property (nonatomic,weak) UILabel *youpaiptitleL; @property (nonatomic,weak) UILabel *youpaipdescL; @property (nonatomic,weak) UIButton *youpaipswitchBtn; @property (nonatomic,strong) YOUPAILZVipSetterModel *youpaipmodel; @end @implementation YOUPAILZVipSetterCell -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { self.selectionStyle = UITableViewCellSelectionStyleNone; self.backgroundColor = [UIColor whiteColor]; [self youpaifinitUI]; } return self; } - (void)youpaifinitUI{ UIButton *switchBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [switchBtn setImage:[UIImage imageNamed:@"vqu_images_ic_profile_siwch_on"] forState:UIControlStateSelected]; [switchBtn setImage:[UIImage imageNamed:@"vqu_images_ic_profile_siwch_off"] forState:UIControlStateNormal]; [switchBtn addTarget:self action:@selector(youpaifswitchBtnClick:) forControlEvents:UIControlEventTouchUpInside]; [self.contentView addSubview:switchBtn]; self.youpaipswitchBtn = switchBtn; [switchBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.offset(-14.0f); make.centerY.equalTo(self.contentView); make.size.mas_offset(CGSizeMake(40, 22)); }]; UILabel *titleL = [[UILabel alloc] init]; titleL.font = LCFont(14.0f); titleL.textColor = LZ273145Color; [self.contentView addSubview:titleL]; self.youpaiptitleL = titleL; [titleL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(14.0f); make.bottom.equalTo(self.contentView.mas_centerY).offset(-3.0f); make.right.equalTo(switchBtn.mas_left).offset(-14.0f); }]; UILabel *descL = [[UILabel alloc] init]; descL.font = LCFont(12.0f); descL.textColor = LZA3AABEColor; descL.numberOfLines = 0; [self.contentView addSubview:descL]; self.youpaipdescL = descL; [descL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(14.0f); make.top.equalTo(self.contentView.mas_centerY).offset(3.0f); make.right.equalTo(switchBtn.mas_left).offset(-14.0f); }]; [self.contentView addLineWithColor:LZF5F4F7Color lineRect:CGRectMake(14.0f, 69.0f, KScreenWidth - 28.0f, 1.0f)]; } - (void)youpaifreloadWithModel:(YOUPAILZVipSetterModel *)model{ self.youpaipmodel = model; self.youpaiptitleL.text = model.youpaipname; self.youpaipdescL.text = model.youpaipdesc; self.youpaipswitchBtn.hidden = model.youpaipdisabled; self.youpaipswitchBtn.selected = model.youpaipstatus == 1; } - (void)youpaifswitchBtnClick:(UIButton *)sender{ sender.selected = !sender.selected; self.youpaipmodel.youpaipstatus = sender.selected ? 1 : 2; if(self.switchBlock != nil){ self.switchBlock(self.youpaipmodel); } } @end