猎豆优选

LDWithdrawTextView.m 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. //
  2. // LDWithdrawTextView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/7/31.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDWithdrawTextView.h"
  9. @interface LDWithdrawTextView ()
  10. @property (nonatomic, strong) UILabel *moneyLogo;
  11. @property (nonatomic, strong) UITextField *moneyField;
  12. @property (nonatomic, strong) UILabel *totalNum;
  13. @property (nonatomic, strong) UIButton *allBtn;
  14. @property (nonatomic, strong) UILabel *line;
  15. @property (nonatomic,strong)UILabel *tipeLabel;
  16. @end
  17. @implementation LDWithdrawTextView
  18. - (instancetype)initWithFrame:(CGRect)frame {
  19. self = [super initWithFrame:frame];
  20. if (self) {
  21. [self initSubViews];
  22. }
  23. return self;
  24. }
  25. - (void)initSubViews {
  26. [self addSubview:self.tipeLabel];
  27. [self addSubview:self.moneyLogo];
  28. [self addSubview:self.moneyField];
  29. [self addSubview:self.line];
  30. [self addSubview:self.totalNum];
  31. [self addSubview:self.allBtn];
  32. [self.tipeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.left.mas_equalTo(Fitsize(13));
  34. make.top.mas_equalTo(FITSIZE(15));
  35. make.width.mas_equalTo(FITSIZE(70));
  36. make.height.mas_equalTo(FITSIZE(20));
  37. }];
  38. [self.moneyLogo mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.left.mas_equalTo(Fitsize(14));
  40. make.top.mas_equalTo(self.tipeLabel.mas_bottom).mas_offset(FITSIZE(14));
  41. make.height.mas_equalTo(FITSIZE(50));
  42. }];
  43. [self.moneyField mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.left.mas_equalTo(self.moneyLogo.mas_right).mas_offset(3);
  45. make.bottom.mas_equalTo(self.moneyLogo.mas_bottom).mas_offset(Fitsize(2));
  46. make.width.mas_equalTo(Fitsize(310));
  47. make.height.mas_equalTo(Fitsize(65));
  48. }];
  49. [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.right.mas_equalTo(-Fitsize(15));
  51. make.left.mas_equalTo(Fitsize(15));
  52. make.height.mas_equalTo(0.5);
  53. make.top.mas_equalTo(self.moneyField.mas_bottom).mas_offset(Fitsize(1));
  54. }];
  55. [self.totalNum mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.left.mas_equalTo(self.moneyLogo);
  57. make.top.mas_equalTo(self.line.mas_bottom).mas_offset(Fitsize(9));
  58. make.height.mas_equalTo(Fitsize(20));
  59. }];
  60. [self.allBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.right.mas_equalTo(-Fitsize(14));
  62. make.width.mas_equalTo(Fitsize(80));
  63. make.height.mas_equalTo(Fitsize(20));
  64. make.centerY.mas_equalTo(self.totalNum.mas_centerY);
  65. }];
  66. }
  67. - (void)allWithdrawAction {
  68. self.moneyField.text = [NSString stringWithFormat:@"%.2f",[self.moneyStr floatValue]];
  69. }
  70. - (NSString *)getMoneyFieldText {
  71. return self.moneyField.text;
  72. }
  73. - (void)setMoneyStr:(NSString *)moneyStr {
  74. _moneyStr = moneyStr;
  75. CGFloat money = [moneyStr floatValue];
  76. self.totalNum.text = [NSString stringWithFormat:@"可提现金额¥%.2f",money];
  77. [self.moneyField becomeFirstResponder];
  78. }
  79. #pragma mark ----
  80. -(UILabel *)tipeLabel
  81. {
  82. if (!_tipeLabel) {
  83. _tipeLabel =[[UILabel alloc]init];
  84. _tipeLabel.text = @"提现金额";
  85. _tipeLabel.textColor = [UIColor YHColorWithHex:0x666666];
  86. _tipeLabel.font = [UIFont systemFontOfSize:Fitsize(15)];
  87. }
  88. return _tipeLabel;
  89. }
  90. - (UILabel *)moneyLogo {
  91. if (!_moneyLogo) {
  92. _moneyLogo = [[UILabel alloc] init];
  93. _moneyLogo.text = @"¥";
  94. _moneyLogo.textColor = [UIColor YHColorWithHex:0x333333];
  95. _moneyLogo.font = [UIFont systemFontOfSize:Fitsize(36)];
  96. }
  97. return _moneyLogo;
  98. }
  99. - (UITextField *)moneyField {
  100. if (!_moneyField) {
  101. _moneyField = [[UITextField alloc] init];
  102. _moneyField.textColor = [UIColor YHColorWithHex:0x000000];
  103. _moneyField.font = [UIFont systemFontOfSize:Fitsize(48)];
  104. _moneyField.keyboardType = UIKeyboardTypeDecimalPad;
  105. _moneyField.clearButtonMode = UITextFieldViewModeAlways;
  106. }
  107. return _moneyField;
  108. }
  109. - (UILabel *)line {
  110. if (!_line) {
  111. _line = [[UILabel alloc] init];
  112. _line.backgroundColor = [UIColor YHColorWithHex:0xE5E5E5];
  113. }
  114. return _line;
  115. }
  116. - (UILabel *)totalNum {
  117. if (!_totalNum) {
  118. _totalNum = [[UILabel alloc] init];
  119. _totalNum.font = [UIFont systemFontOfSize:Fitsize(14)];
  120. _totalNum.textColor = [UIColor YHColorWithHex:0x888888];
  121. CGFloat money = [self.moneyStr floatValue];
  122. _totalNum.text = [NSString stringWithFormat:@"可提现金额¥%.2f",money];
  123. }
  124. return _totalNum;
  125. }
  126. - (UIButton *)allBtn {
  127. if (!_allBtn) {
  128. _allBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  129. [_allBtn setTitle:@"全部提现" forState:UIControlStateNormal];
  130. [_allBtn setTitleColor:[UIColor homeRedColor] forState:UIControlStateNormal];
  131. _allBtn.titleLabel.font = [UIFont systemFontOfSize:Fitsize(14)];
  132. [_allBtn addTarget:self action:@selector(allWithdrawAction) forControlEvents:UIControlEventTouchUpInside];
  133. }
  134. return _allBtn;
  135. }
  136. @end