reNameRecordFileView.m 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. //
  2. // reNameRecordFileView.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2025/4/7.
  6. //
  7. #import "reNameRecordFileView.h"
  8. @interface reNameRecordFileView ()
  9. @property(nonatomic,strong)UITextField *nameTF;
  10. @end
  11. @implementation reNameRecordFileView
  12. - (id)initWithFrame:(CGRect)frame{
  13. self = [super initWithFrame:frame];
  14. self.backgroundColor = [UIColor hwColor:@"000000" alpha:0.6];
  15. [self drawAnyView];
  16. return self;
  17. }
  18. -(void)drawAnyView{
  19. UIView *whiteBgView = [[UIView alloc] init];
  20. whiteBgView.backgroundColor = [UIColor whiteColor];
  21. whiteBgView.layer.cornerRadius = 8.0;
  22. [self addSubview:whiteBgView];
  23. [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  24. make.width.mas_equalTo(300.f);
  25. make.height.mas_equalTo(221.f);
  26. make.centerX.mas_equalTo(0.f);
  27. make.centerY.mas_equalTo(-100.f);
  28. }];
  29. UILabel *nameLab = [[UILabel alloc] init];
  30. nameLab.text = NSLocalizedString(@"record_reName_title",nil);
  31. nameLab.textAlignment = NSTextAlignmentCenter;
  32. nameLab.textColor = [UIColor hwColor:@"#151515"];
  33. nameLab.font = [UIFont systemFontOfSize:18.0];
  34. [whiteBgView addSubview:nameLab];
  35. [nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.mas_equalTo(0.f);
  37. make.height.mas_equalTo(20.f);
  38. make.right.mas_equalTo(0.f);
  39. make.top.mas_equalTo(25.f);
  40. }];
  41. UIView *bgView = [[UIView alloc] init];
  42. bgView.backgroundColor = [UIColor hwColor:@"#EEEEEE"];
  43. bgView.layer.cornerRadius = 8.0;
  44. [whiteBgView addSubview:bgView];
  45. [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.left.mas_equalTo(30.f);
  47. make.height.mas_equalTo(44.f);
  48. make.right.mas_equalTo(-30.f);
  49. make.top.equalTo(nameLab.mas_bottom).offset(22.0);
  50. }];
  51. _nameTF = [[UITextField alloc] init];
  52. _nameTF.backgroundColor = [UIColor clearColor];
  53. _nameTF.textColor = [UIColor hwColor:@"0A132B"];
  54. //_nameTF.textAlignment = NSTextAlignmentCenter;
  55. _nameTF.font = [UIFont systemFontOfSize:14.0];
  56. [bgView addSubview:_nameTF];
  57. _nameTF.placeholder = NSLocalizedString(@"record_reName_placeholder",nil);
  58. [_nameTF setTintColor:[UIColor hwColor:@"#01B7EA" alpha:1.0]];
  59. [_nameTF mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.left.mas_equalTo(10);
  61. make.right.mas_equalTo(-10);
  62. make.top.mas_equalTo(0);
  63. make.bottom.mas_equalTo(0);
  64. }];
  65. UIButton *rightDeleteBut = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 16, 16)];
  66. [rightDeleteBut setBackgroundImage:[UIImage imageNamed:@"rename_close_icon"] forState:UIControlStateNormal];
  67. rightDeleteBut.tag = 1;
  68. [rightDeleteBut addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  69. _nameTF.rightView = rightDeleteBut;
  70. _nameTF.rightViewMode = UITextFieldViewModeWhileEditing;
  71. UIButton*cancelBut = [[UIButton alloc] init];
  72. cancelBut.backgroundColor = [UIColor hwColor:@"#E3E8F1"];
  73. [cancelBut setTitleColor:[UIColor hwColor:@"#0A132B"] forState:(UIControlStateNormal)];
  74. cancelBut.layer.cornerRadius = 8;
  75. [cancelBut setTitle:NSLocalizedString(@"other_cancel",nil) forState:UIControlStateNormal];
  76. [whiteBgView addSubview:cancelBut];
  77. cancelBut.tag = 2;
  78. [cancelBut addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  79. [cancelBut mas_makeConstraints:^(MASConstraintMaker *make) {
  80. make.left.mas_equalTo(30);
  81. make.width.mas_equalTo(110);
  82. make.height.mas_equalTo(40);
  83. make.bottom.mas_equalTo(-30);
  84. }];
  85. UIButton*OkBut = [[UIButton alloc] init];
  86. OkBut.backgroundColor = [UIColor hwColor:@"#E3E8F1"];
  87. [OkBut setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  88. OkBut.layer.cornerRadius = 8;
  89. OkBut.layer.masksToBounds = YES;
  90. [OkBut setTitle:NSLocalizedString(@"other_confirm",nil) forState:UIControlStateNormal];
  91. [whiteBgView addSubview:OkBut];
  92. OkBut.tag = 3;
  93. [OkBut addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  94. [OkBut mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.right.mas_equalTo(-30);
  96. make.width.mas_equalTo(110);
  97. make.height.mas_equalTo(40);
  98. make.bottom.mas_equalTo(-30);
  99. }];
  100. // gradient
  101. CAGradientLayer *gl = [CAGradientLayer layer];
  102. gl.frame = CGRectMake(0,0,110,40.f);
  103. gl.startPoint = CGPointMake(0, 0.5);
  104. gl.endPoint = CGPointMake(1, 0.5);
  105. gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
  106. gl.locations = @[@(0), @(1.0f)];
  107. [OkBut.layer addSublayer:gl];
  108. }
  109. - (void)setFileName:(NSString *)fileName
  110. {
  111. _nameTF.text = fileName;
  112. }
  113. #pragma mark 按钮点击事件
  114. - (void)didClickButtonFun:(UIButton*)but
  115. {
  116. NSInteger tag = but.tag;
  117. if (tag == 1) {
  118. _nameTF.text = @"";
  119. }
  120. else if (tag == 2){
  121. [self removeFromSuperview];
  122. }
  123. else if (tag == 3){
  124. if (_didClickOkButtonFun) {
  125. NSString *name = [_nameTF.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
  126. _didClickOkButtonFun(name);
  127. }
  128. }
  129. }
  130. @end