// // YOUPAILCCommonSwitchCell.m // LiveChat // // Created by 张灿 on 2018/8/26. // Copyright © 2018年 caicai. All rights reserved. // #import "YOUPAILCCommonSwitchCell.h" @implementation YOUPAILCCommonSwitchCell - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { self.selectionStyle = UITableViewCellSelectionStyleNone; //v.1.5.6适配暗黑模式 [self.contentView setBackgroundColor:[UIColor whiteColor]]; self.youpaipcanSwitch = YES; [self youpaifinitUI]; } return self; } - (void)youpaifinitUI{ // self.baseView = [[UIView alloc]initWithFrame:CGRectMake(16,0,KScreenWidth-32,45)]; // self.baseView.backgroundColor = [UIColor whiteColor]; // [self.contentView addSubview:self.baseView]; self.youpaipline = [[UIView alloc]initWithFrame:CGRectMake(14,44.5,KScreenWidth-28,0.5)]; self.youpaipline.backgroundColor = [UIColor whiteColor]; [self.contentView addSubview:self.youpaipline]; self.youpaipheadLabel = [[UILabel alloc]init]; self.youpaipheadLabel.font = LCBoldFont(14.0f); self.youpaipheadLabel.textColor = LZ273145Color; self.youpaipheadLabel.textAlignment = NSTextAlignmentLeft; [self.contentView addSubview:self.youpaipheadLabel]; [self.youpaipheadLabel makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.mas_left).offset(19); make.top.equalTo(@14); make.height.equalTo(@17); }]; self.youpaiprightBtn = [[UIButton alloc]init]; self.youpaiprightBtn.titleLabel.font = [UIFont systemFontOfSize:14]; // self.rightLabel.textColor = HexColorFromRGB(0xffffff); [self.contentView addSubview:self.youpaiprightBtn]; [self.youpaiprightBtn makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-19); make.top.equalTo(@14); make.size.mas_equalTo(CGSizeMake(50, 20)); }]; self.youpaiprightBtn.titleLabel.textAlignment = NSTextAlignmentRight; self.youpaipcommonSwitch = [[UIButton alloc]init]; // self.commonSwitch.backgroundColor = HexColorFromRGB(0xcccccc); // self.commonSwitch.layer.cornerRadius = 15; // self.commonSwitch.onTintColor = HexColorFromRGB(0x6CE980); [self.contentView addSubview:self.youpaipcommonSwitch]; [self.youpaipcommonSwitch makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.mas_right).offset(-19); make.centerY.equalTo(self.contentView); make.size.mas_equalTo(CGSizeMake(40, 22)); }]; [self.youpaipcommonSwitch setImage:[UIImage imageNamed:@"vqu_images_ic_profile_siwch_on"] forState:UIControlStateSelected]; [self.youpaipcommonSwitch setImage:[UIImage imageNamed:@"vqu_images_ic_profile_siwch_off"] forState:UIControlStateNormal]; // self.commonSwitch.transform = CGAffineTransformMakeScale(39/self.commonSwitch.frame.size.width,24/self.commonSwitch.frame.size.height); // self.commonSwitch.centerY = 22.5; // self.commonSwitch.centerX = 26.5; } - (void)setYoupaipcanSwitch:(BOOL)canSwitch{ _youpaipcanSwitch = canSwitch; if (canSwitch) { self.youpaipcommonSwitch.userInteractionEnabled = YES; self.youpaipcommonSwitch.alpha = 1.0; }else{ self.youpaipcommonSwitch.userInteractionEnabled = NO; self.youpaipcommonSwitch.alpha = 0.5; } } @end