You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
134 lines
4.3 KiB
134 lines
4.3 KiB
![]()
2 years ago
|
//
|
||
|
// DeviceSubmenuTableViewCell.m
|
||
|
// tongxin
|
||
|
//
|
||
|
// Created by ecell on 2023/7/11.
|
||
|
// Copyright © 2023 xTT. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "DeviceSubmenuTableViewCell.h"
|
||
|
|
||
|
@interface DeviceSubmenuTableViewCell ()
|
||
|
|
||
|
@property (nonatomic ,weak) UIImageView *leftImg;
|
||
|
@property (nonatomic ,weak) UILabel *titleLabel;
|
||
|
@property (nonatomic ,weak) UIImageView *rightImg;
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation DeviceSubmenuTableViewCell
|
||
|
|
||
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
|
||
|
{
|
||
|
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||
|
if (self)
|
||
|
{
|
||
|
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||
|
self.backgroundColor = KKWhiteColorColor;
|
||
|
[self subCellView];
|
||
|
}
|
||
|
|
||
|
return self;
|
||
|
}
|
||
|
- (void)setTitleStr:(NSString *)titleStr
|
||
|
{
|
||
|
_titleStr = titleStr;
|
||
|
self.titleLabel.text = titleStr;
|
||
|
self.rightImg.hidden = [titleStr isEqualToString:@"定位模式"] ? NO : YES;
|
||
|
self.textsLabel.hidden = [titleStr isEqualToString:@"定位模式"] ? NO : YES;
|
||
|
self.customSwitch.hidden = ![titleStr isEqualToString:@"定位模式"] ? NO : YES;
|
||
|
|
||
|
}
|
||
|
|
||
|
- (void)setImageStr:(NSString *)imageStr
|
||
|
{
|
||
|
_imageStr = imageStr;
|
||
|
self.leftImg.image = ImageName_(imageStr);
|
||
|
}
|
||
|
|
||
|
- (void)subCellView
|
||
|
{
|
||
|
|
||
|
/// 右箭头图片
|
||
|
UIImageView *leftImg = [UICommon ui_imageView:CGRectZero fileName:@""];
|
||
|
self.leftImg = leftImg;
|
||
|
[self.contentView addSubview:leftImg];
|
||
|
[leftImg mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.left.equalTo(self.contentView).offset(19);
|
||
|
make.centerY.equalTo(self.contentView.mas_centerY);
|
||
|
make.size.mas_equalTo(CGSizeMake(22, 22));
|
||
|
}];
|
||
|
|
||
|
|
||
|
UILabel *titleLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:Font_(16) textColor:KKTextColor text:@"" Radius:0];
|
||
|
self.titleLabel = titleLabel;
|
||
|
[self.contentView addSubview:titleLabel];
|
||
|
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.left.equalTo(leftImg.mas_right).offset(15);
|
||
|
make.centerY.equalTo(self.contentView);
|
||
|
}];
|
||
|
|
||
|
/// 右箭头图片
|
||
|
UIImageView *rightImg = [UICommon ui_imageView:CGRectZero fileName:@"comm_right_icon"];
|
||
|
rightImg.hidden = YES;
|
||
|
self.rightImg = rightImg;
|
||
|
[self.contentView addSubview:rightImg];
|
||
|
[rightImg mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.right.equalTo(self.contentView.mas_right).inset(15);
|
||
|
make.centerY.equalTo(self.contentView.mas_centerY);
|
||
|
make.size.mas_equalTo(CGSizeMake(7.5, 15));
|
||
|
}];
|
||
|
|
||
|
|
||
|
UILabel *textsLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:Font_(13) textColor:mainColor text:@"" Radius:0];
|
||
|
self.textsLabel = textsLabel;
|
||
|
[self.contentView addSubview:textsLabel];
|
||
|
[textsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.right.equalTo(rightImg.mas_left).inset(15);
|
||
|
make.centerY.equalTo(self.contentView);
|
||
|
}];
|
||
|
|
||
|
|
||
|
UISwitch *customSwitch = [[UISwitch alloc] init];
|
||
|
[customSwitch setOnTintColor:mainColor];
|
||
|
[customSwitch addTarget:self action:@selector(switchBtnClick:) forControlEvents:UIControlEventValueChanged];
|
||
|
customSwitch.hidden = YES;
|
||
|
self.customSwitch = customSwitch;
|
||
|
[self.contentView addSubview:customSwitch];
|
||
|
[customSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.right.equalTo(self.contentView.mas_right).inset(15);
|
||
|
make.centerY.equalTo(self.contentView);
|
||
|
//make.size.mas_equalTo(CGSizeMake(Adapted(80), Adapted(40)));
|
||
|
}];
|
||
|
|
||
|
UILabel *line = [UILabel new];
|
||
|
line.backgroundColor = RGB(235, 235, 235);
|
||
|
self.line = line;
|
||
|
[self.contentView addSubview:line];
|
||
|
[line mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.left.right.equalTo(self.contentView);
|
||
|
make.bottom.equalTo(self.contentView.mas_bottom).inset(0.5);
|
||
|
make.height.mas_equalTo(0.5);
|
||
|
}];
|
||
|
|
||
|
}
|
||
|
|
||
|
-(void)switchBtnClick:(id)sender{
|
||
|
if(self.cellBack){
|
||
|
self.cellBack(sender,self);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- (void)awakeFromNib {
|
||
|
[super awakeFromNib];
|
||
|
// Initialization code
|
||
|
}
|
||
|
|
||
|
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
||
|
[super setSelected:selected animated:animated];
|
||
|
|
||
|
// Configure the view for the selected state
|
||
|
}
|
||
|
|
||
|
@end
|