// // EditPayView.m // YBVideo // // Created by ybRRR on 2023/7/12. // Copyright © 2023 cat. All rights reserved. // #import "EditPayView.h" @interface EditPayView () { UITextField *coinTextField; UIView *whiteView; } @end @implementation EditPayView -(instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if(self){ self.backgroundColor = RGBA(1, 1, 1, 0.4); UITapGestureRecognizer *closeTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(closeTapClick)]; closeTap.delegate = self; [self addGestureRecognizer:closeTap]; [self createUI]; } return self; } -(void)createUI{ whiteView = [[UIView alloc]init]; whiteView.frame = CGRectMake(0, 0, _window_width *0.7, _window_width *0.7*0.6); whiteView.backgroundColor = UIColor.whiteColor; whiteView.layer.cornerRadius = 10; whiteView.layer.masksToBounds = YES; whiteView.center = self.center; [self addSubview:whiteView]; UILabel *titleLb = [[UILabel alloc]init]; titleLb.frame = CGRectMake(0, 10, whiteView.width, 20); titleLb.text = YZMsg(@"请输入要投放的金额"); titleLb.font = [UIFont systemFontOfSize:16]; titleLb.textColor = UIColor.blackColor; titleLb.textAlignment = NSTextAlignmentCenter; [whiteView addSubview:titleLb]; coinTextField = [[UITextField alloc]init]; coinTextField.frame = CGRectMake(12, titleLb.bottom+8, whiteView.width-24, 36); coinTextField.layer.borderColor = UIColor.lightGrayColor.CGColor; coinTextField.layer.borderWidth = 1; coinTextField.font = [UIFont systemFontOfSize:14]; coinTextField.textColor = UIColor.blackColor; coinTextField.keyboardType = UIKeyboardTypeNumberPad; coinTextField.textAlignment = NSTextAlignmentCenter; [whiteView addSubview:coinTextField]; UILabel *tipsLb = [[UILabel alloc]init]; tipsLb.frame = CGRectMake(coinTextField.left, coinTextField.bottom+5, coinTextField.width, 15); tipsLb.text = YZMsg(@"金额不可低于100,且为10的倍数"); tipsLb.font = [UIFont systemFontOfSize:11]; tipsLb.textColor = UIColor.grayColor; [whiteView addSubview:tipsLb]; UIButton *sureBtn = [UIButton buttonWithType:0]; sureBtn.frame = CGRectMake(whiteView.width/2-(whiteView.width *0.6)/2, whiteView.height-44, whiteView.width *0.6, 36); [sureBtn setBackgroundColor:Pink_Cor]; [sureBtn setTitle:YZMsg(@"确定") forState:0]; [sureBtn setTitleColor:UIColor.whiteColor forState:0]; sureBtn.titleLabel.font = [UIFont systemFontOfSize:14]; sureBtn.layer.cornerRadius = 18; sureBtn.layer.masksToBounds = YES; [sureBtn addTarget:self action:@selector(sureBtnClick) forControlEvents:UIControlEventTouchUpInside]; [whiteView addSubview:sureBtn]; } - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{ NSLog(@"s0000000000:%@",NSStringFromClass([touch.view class])); if ([touch.view isDescendantOfView:whiteView]) { return NO; } return YES; } -(void)sureBtnClick{ if(coinTextField.text.length < 1){ [MBProgressHUD showError:YZMsg(@"请输入要投放的金额")]; return; } if(self.closeEvent){ self.closeEvent(@"确定",coinTextField.text); } } -(void)closeTapClick{ if(self.closeEvent){ self.closeEvent(@"关闭",@""); } } @end