ECModifyingGroupCollCell.m 4.3 KB
//
//  ECModifyingGroupCollCell.m
//  EducationContact
//
//  Created by Apple on 2022/8/1.
//

#import "ECModifyingGroupCollCell.h"

@interface ECModifyingGroupCollCell ()<UITextFieldDelegate>

@property (nonatomic,strong) UITextField *textField;
@property (nonatomic,strong) UILabel *lab;
@property (nonatomic,strong) UIImageView *imgV;
@property (nonatomic,strong) UIImageView *defImgV;

@end

@implementation ECModifyingGroupCollCell

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self creatCellView];
    }
    return self;
}
-(void)creatCellView{
    
    self.contentView.backgroundColor = [UIColor whiteColor];
    
    self.textField = [[UITextField alloc]init];
    self.textField.placeholder = @"请输入";
    self.textField.font = [UIFont systemFontOfSize:14];
    self.textField.textColor = COLOR_WITH_HEX(0x333333);
    self.textField.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.textField];
    self.textField.sd_layout.leftSpaceToView(self.contentView, 0).rightSpaceToView(self.contentView, 8).topSpaceToView(self.contentView, 8).bottomSpaceToView(self.contentView, 0);
    [self.textField.layer setMasksToBounds:YES];
    [self.textField.layer setBorderWidth:1];
    [self.textField.layer setBorderColor:COLOR_WITH_HEX(0xB1BDC2).CGColor];
    [self.textField.layer setCornerRadius:6];
    self.textField.hidden = YES;
    self.textField.delegate = self;
    
    self.lab = [[UILabel alloc]init];
    self.lab.font = [UIFont systemFontOfSize:14];
    self.lab.textColor = COLOR_WITH_HEX(0x333333);
    self.lab.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.lab];
    self.lab.sd_layout.leftSpaceToView(self.contentView, 0).rightSpaceToView(self.contentView, 8).topSpaceToView(self.contentView, 8).bottomSpaceToView(self.contentView, 0);
    [self.lab.layer setMasksToBounds:YES];
    [self.lab.layer setBorderWidth:1];
    [self.lab.layer setBorderColor:COLOR_WITH_HEX(0xB1BDC2).CGColor];
    [self.lab.layer setCornerRadius:6];
    self.lab.hidden = YES;
    
    self.imgV = [[UIImageView alloc]init];
    [self.contentView addSubview:self.imgV];
    self.imgV.sd_layout.leftSpaceToView(self.contentView, 0).rightSpaceToView(self.contentView, 8).topSpaceToView(self.contentView, 8).bottomSpaceToView(self.contentView, 0);
    self.imgV.hidden = YES;
    
    self.defImgV = [[UIImageView alloc]init];
    [self.contentView addSubview:self.defImgV];
    self.defImgV.sd_layout.leftSpaceToView(self.contentView, 0).rightSpaceToView(self.contentView, 8).topSpaceToView(self.contentView, 8).bottomSpaceToView(self.contentView, 0);
    self.defImgV.hidden = YES;
    
    self.deleBtn = [[UIButton alloc]init];
    [self.deleBtn setImage:[UIImage imageNamed:@"close_orange_icon"] forState:UIControlStateNormal];
    [self.contentView addSubview:self.deleBtn];
    self.deleBtn.sd_layout.rightSpaceToView(self.contentView, 0).topSpaceToView(self.contentView, 0).widthIs(16).heightIs(16);
}

-(void)setImgModel:(ECGroupImagesModel *)imgModel
{
    self.lab.hidden = YES;
    self.textField.hidden = YES;
    self.imgV.hidden = NO;
    self.defImgV.hidden = YES;
    _imgModel = imgModel;
    if (imgModel.cdnUrl != nil) {
        [self.imgV sd_setImageWithURL:[NSURL URLWithString:imgModel.cdnUrl]];

    }
}

-(void)setImgnew:(UIImage *)imgnew
{
    self.lab.hidden = YES;
    self.textField.hidden = YES;
    self.imgV.hidden = NO;
    self.defImgV.hidden = YES;
    self.imgV.image = imgnew;

    
}

-(void)setTitleModel:(NSString *)titleModel
{
    self.lab.hidden = NO;
    self.textField.hidden = NO;
    self.imgV.hidden = YES;
    self.defImgV.hidden = YES;
    _titleModel = titleModel;
    if ([titleModel isEqualToString:@""] || titleModel == nil) {
        self.textField.hidden = NO;
        self.lab.hidden = YES;
    }else{
        self.textField.hidden = YES;
        self.lab.text = titleModel;
        self.lab.hidden = NO;
    }
}
-(void)setDefImg:(UIImage *)defImg
{
    self.lab.hidden = YES;
    self.textField.hidden = YES;
    self.imgV.hidden = YES;
    self.defImgV.hidden = NO;
    self.defImgV.image = defImg;
}

-(void)textFieldDidEndEditing:(UITextField *)textField
{
    if ([self.deletegate respondsToSelector:@selector(baclCellStr:andImgStr:andTag:)]) {
        [self.deletegate baclCellStr:textField.text andImgStr:@"" andTag:self.tag];
    }
}

@end