// // reNameRecordFileView.m // 双子星云手机 // // Created by xd h on 2025/4/7. // #import "reNameRecordFileView.h" @interface reNameRecordFileView () @property(nonatomic,strong)UITextField *nameTF; @end @implementation reNameRecordFileView - (id)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; self.backgroundColor = [UIColor hwColor:@"000000" alpha:0.6]; [self drawAnyView]; return self; } -(void)drawAnyView{ UIView *whiteBgView = [[UIView alloc] init]; whiteBgView.backgroundColor = [UIColor whiteColor]; whiteBgView.layer.cornerRadius = 8.0; [self addSubview:whiteBgView]; [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.width.mas_equalTo(300.f); make.height.mas_equalTo(221.f); make.centerX.mas_equalTo(0.f); make.centerY.mas_equalTo(-100.f); }]; UILabel *nameLab = [[UILabel alloc] init]; nameLab.text = NSLocalizedString(@"record_reName_title",nil); nameLab.textAlignment = NSTextAlignmentCenter; nameLab.textColor = [UIColor hwColor:@"#151515"]; nameLab.font = [UIFont systemFontOfSize:18.0]; [whiteBgView addSubview:nameLab]; [nameLab mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0.f); make.height.mas_equalTo(20.f); make.right.mas_equalTo(0.f); make.top.mas_equalTo(25.f); }]; UIView *bgView = [[UIView alloc] init]; bgView.backgroundColor = [UIColor hwColor:@"#EEEEEE"]; bgView.layer.cornerRadius = 8.0; [whiteBgView addSubview:bgView]; [bgView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(30.f); make.height.mas_equalTo(44.f); make.right.mas_equalTo(-30.f); make.top.equalTo(nameLab.mas_bottom).offset(22.0); }]; _nameTF = [[UITextField alloc] init]; _nameTF.backgroundColor = [UIColor clearColor]; _nameTF.textColor = [UIColor hwColor:@"0A132B"]; //_nameTF.textAlignment = NSTextAlignmentCenter; _nameTF.font = [UIFont systemFontOfSize:14.0]; [bgView addSubview:_nameTF]; _nameTF.placeholder = NSLocalizedString(@"record_reName_placeholder",nil); [_nameTF setTintColor:[UIColor hwColor:@"#01B7EA" alpha:1.0]]; [_nameTF mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.right.mas_equalTo(-10); make.top.mas_equalTo(0); make.bottom.mas_equalTo(0); }]; UIButton *rightDeleteBut = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 16, 16)]; [rightDeleteBut setBackgroundImage:[UIImage imageNamed:@"rename_close_icon"] forState:UIControlStateNormal]; rightDeleteBut.tag = 1; [rightDeleteBut addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside]; _nameTF.rightView = rightDeleteBut; _nameTF.rightViewMode = UITextFieldViewModeWhileEditing; UIButton*cancelBut = [[UIButton alloc] init]; cancelBut.backgroundColor = [UIColor hwColor:@"#E3E8F1"]; [cancelBut setTitleColor:[UIColor hwColor:@"#0A132B"] forState:(UIControlStateNormal)]; cancelBut.layer.cornerRadius = 8; [cancelBut setTitle:NSLocalizedString(@"other_cancel",nil) forState:UIControlStateNormal]; [whiteBgView addSubview:cancelBut]; cancelBut.tag = 2; [cancelBut addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside]; [cancelBut mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(30); make.width.mas_equalTo(110); make.height.mas_equalTo(40); make.bottom.mas_equalTo(-30); }]; UIButton*OkBut = [[UIButton alloc] init]; OkBut.backgroundColor = [UIColor hwColor:@"#E3E8F1"]; [OkBut setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)]; OkBut.layer.cornerRadius = 8; OkBut.layer.masksToBounds = YES; [OkBut setTitle:NSLocalizedString(@"other_confirm",nil) forState:UIControlStateNormal]; [whiteBgView addSubview:OkBut]; OkBut.tag = 3; [OkBut addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside]; [OkBut mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-30); make.width.mas_equalTo(110); make.height.mas_equalTo(40); make.bottom.mas_equalTo(-30); }]; // gradient CAGradientLayer *gl = [CAGradientLayer layer]; gl.frame = CGRectMake(0,0,110,40.f); gl.startPoint = CGPointMake(0, 0.5); gl.endPoint = CGPointMake(1, 0.5); gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor]; gl.locations = @[@(0), @(1.0f)]; [OkBut.layer addSublayer:gl]; } - (void)setFileName:(NSString *)fileName { _nameTF.text = fileName; } #pragma mark 按钮点击事件 - (void)didClickButtonFun:(UIButton*)but { NSInteger tag = but.tag; if (tag == 1) { _nameTF.text = @""; } else if (tag == 2){ [self removeFromSuperview]; } else if (tag == 3){ if (_didClickOkButtonFun) { NSString *name = [_nameTF.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; _didClickOkButtonFun(name); } } } @end