// // MineViewCell.m // VclustersGemini // // Created by 黄盛威 on 2020/10/19. // Copyright © 2020 APPLE. All rights reserved. // #import "MineViewCell.h" @implementation MineViewCell @synthesize cellBgView; @synthesize mImageView; @synthesize titleLabel; @synthesize titleLabel2; @synthesize rightImage; @synthesize lineView; @synthesize maskSwitch; - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { [self drawView]; } return self; } - (void)drawView { cellBgView = [[UIView alloc] init]; [self.contentView addSubview:cellBgView]; cellBgView.backgroundColor = [UIColor whiteColor]; [cellBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(15.f); make.top.mas_equalTo(0); make.bottom.mas_equalTo(0); make.width.mas_equalTo(SCREEN_W - 2*15.f); }]; /*图片*/ mImageView = [[UIImageView alloc] init]; [mImageView setBackgroundColor:[UIColor clearColor]]; [cellBgView addSubview:mImageView]; [mImageView setContentMode:(UIViewContentModeScaleAspectFill)]; [mImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(15); make.width.mas_equalTo(28); make.height.mas_equalTo(28); make.centerY.equalTo(cellBgView.mas_centerY); }]; /*右侧箭头*/ rightImage = [[UIImageView alloc] init]; [rightImage setBackgroundColor:[UIColor clearColor]]; [rightImage setImage:[UIImage imageNamed:@"cell_right_access"]]; [cellBgView addSubview:rightImage]; [rightImage mas_makeConstraints:^(MASConstraintMaker *make) { make.width.mas_equalTo(28); make.right.mas_equalTo(-15.f); make.height.mas_equalTo(28); make.centerY.equalTo(cellBgView.mas_centerY); }]; maskSwitch = [[UISwitch alloc] init]; [cellBgView addSubview:maskSwitch]; [maskSwitch mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-18.f); make.centerY.equalTo(cellBgView.mas_centerY); }]; [maskSwitch setOnTintColor:HW13B2EBColor]; [maskSwitch addTarget:self action:@selector(maskSwitchPressed:) forControlEvents:(UIControlEventValueChanged)]; // BOOL haveOpenMask = [HWDataManager getBoolWithKey:Consn_Fanzhuan_Exit_app_Open]; // [maskSwitch setOn:haveOpenMask]; /**标题*/ titleLabel = [[UILabel alloc] init]; [cellBgView addSubview:titleLabel]; titleLabel.font = [UIFont systemFontOfSize:13.f]; [titleLabel setTextColor:HW0A132BColor]; [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(mImageView.mas_right).offset(5.f); make.right.mas_equalTo(-100.f); make.centerY.equalTo(cellBgView.mas_centerY); }]; /**副标题*/ titleLabel2 = [[UILabel alloc] init]; [cellBgView addSubview:titleLabel2]; titleLabel2.font = [UIFont systemFontOfSize:12.f]; [titleLabel2 setTextAlignment:(NSTextAlignmentRight)]; [titleLabel2 setTextColor:HW666666Color]; [titleLabel2 mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-53.f); make.left.mas_equalTo(100.f); make.centerY.equalTo(cellBgView.mas_centerY); }]; lineView = [[UIView alloc] init]; [lineView setBackgroundColor:HW979797Color10]; [cellBgView addSubview:lineView]; [lineView mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-15.f); make.left.mas_equalTo(15.f); make.bottom.mas_equalTo(0); make.height.mas_equalTo(1.f); }]; } - (void)maskSwitchPressed:(UISwitch *)maskSwitch{ if (_didClickMaskSwitch) { _didClickMaskSwitch(maskSwitch); } else{//之前的逻辑 有时间再完善 [HWDataManager setBoolWithKey:Consn_Fanzhuan_Exit_app_Open value:maskSwitch.on]; if (maskSwitch.on) { [[iToast makeText:NSLocalizedString(@"my_set_no_fanzhuan_exit_open",nil)] show]; [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Overturn_on"]; } else{ [[iToast makeText:NSLocalizedString(@"my_set_no_fanzhuan_exit_close",nil)] show]; [[netWorkManager shareInstance] DataEmbeddingPointBy:3 withEventValue:@"Overturn_off"]; } } } @end