EditPayView.m 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // EditPayView.m
  3. // YBVideo
  4. //
  5. // Created by ybRRR on 2023/7/12.
  6. // Copyright © 2023 cat. All rights reserved.
  7. //
  8. #import "EditPayView.h"
  9. @interface EditPayView ()<UIGestureRecognizerDelegate>
  10. {
  11. UITextField *coinTextField;
  12. UIView *whiteView;
  13. }
  14. @end
  15. @implementation EditPayView
  16. -(instancetype)initWithFrame:(CGRect)frame
  17. {
  18. self = [super initWithFrame:frame];
  19. if(self){
  20. self.backgroundColor = RGBA(1, 1, 1, 0.4);
  21. UITapGestureRecognizer *closeTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(closeTapClick)];
  22. closeTap.delegate = self;
  23. [self addGestureRecognizer:closeTap];
  24. [self createUI];
  25. }
  26. return self;
  27. }
  28. -(void)createUI{
  29. whiteView = [[UIView alloc]init];
  30. whiteView.frame = CGRectMake(0, 0, _window_width *0.7, _window_width *0.7*0.6);
  31. whiteView.backgroundColor = UIColor.whiteColor;
  32. whiteView.layer.cornerRadius = 10;
  33. whiteView.layer.masksToBounds = YES;
  34. whiteView.center = self.center;
  35. [self addSubview:whiteView];
  36. UILabel *titleLb = [[UILabel alloc]init];
  37. titleLb.frame = CGRectMake(0, 10, whiteView.width, 20);
  38. titleLb.text = YZMsg(@"请输入要投放的金额");
  39. titleLb.font = [UIFont systemFontOfSize:16];
  40. titleLb.textColor = UIColor.blackColor;
  41. titleLb.textAlignment = NSTextAlignmentCenter;
  42. [whiteView addSubview:titleLb];
  43. coinTextField = [[UITextField alloc]init];
  44. coinTextField.frame = CGRectMake(12, titleLb.bottom+8, whiteView.width-24, 36);
  45. coinTextField.layer.borderColor = UIColor.lightGrayColor.CGColor;
  46. coinTextField.layer.borderWidth = 1;
  47. coinTextField.font = [UIFont systemFontOfSize:14];
  48. coinTextField.textColor = UIColor.blackColor;
  49. coinTextField.keyboardType = UIKeyboardTypeNumberPad;
  50. coinTextField.textAlignment = NSTextAlignmentCenter;
  51. [whiteView addSubview:coinTextField];
  52. UILabel *tipsLb = [[UILabel alloc]init];
  53. tipsLb.frame = CGRectMake(coinTextField.left, coinTextField.bottom+5, coinTextField.width, 15);
  54. tipsLb.text = YZMsg(@"金额不可低于100,且为10的倍数");
  55. tipsLb.font = [UIFont systemFontOfSize:11];
  56. tipsLb.textColor = UIColor.grayColor;
  57. [whiteView addSubview:tipsLb];
  58. UIButton *sureBtn = [UIButton buttonWithType:0];
  59. sureBtn.frame = CGRectMake(whiteView.width/2-(whiteView.width *0.6)/2, whiteView.height-44, whiteView.width *0.6, 36);
  60. [sureBtn setBackgroundColor:Pink_Cor];
  61. [sureBtn setTitle:YZMsg(@"确定") forState:0];
  62. [sureBtn setTitleColor:UIColor.whiteColor forState:0];
  63. sureBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  64. sureBtn.layer.cornerRadius = 18;
  65. sureBtn.layer.masksToBounds = YES;
  66. [sureBtn addTarget:self action:@selector(sureBtnClick) forControlEvents:UIControlEventTouchUpInside];
  67. [whiteView addSubview:sureBtn];
  68. }
  69. - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
  70. NSLog(@"s0000000000:%@",NSStringFromClass([touch.view class]));
  71. if ([touch.view isDescendantOfView:whiteView]) {
  72. return NO;
  73. }
  74. return YES;
  75. }
  76. -(void)sureBtnClick{
  77. if(coinTextField.text.length < 1){
  78. [MBProgressHUD showError:YZMsg(@"请输入要投放的金额")];
  79. return;
  80. }
  81. if(self.closeEvent){
  82. self.closeEvent(@"确定",coinTextField.text);
  83. }
  84. }
  85. -(void)closeTapClick{
  86. if(self.closeEvent){
  87. self.closeEvent(@"关闭",@"");
  88. }
  89. }
  90. @end