JXCommonInputVC.m 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //
  2. // JXCommonInputVC.m
  3. // shiku_im
  4. //
  5. // Created by p on 2019/4/1.
  6. // Copyright © 2019年 Reese. All rights reserved.
  7. //
  8. #import "JXCommonInputVC.h"
  9. #define HEIGHT 44
  10. #define STARTTIME_TAG 1
  11. #define IMGSIZE 100
  12. @interface JXCommonInputVC ()<UITextFieldDelegate>
  13. @end
  14. @implementation JXCommonInputVC
  15. - (void)viewDidLoad {
  16. [super viewDidLoad];
  17. // Do any additional setup after loading the view.
  18. self.isGotoBack = YES;
  19. self.title = self.titleStr;
  20. self.heightFooter = 0;
  21. self.heightHeader = JX_SCREEN_TOP;
  22. //self.view.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT);
  23. [self createHeadAndFoot];
  24. int h = 0;
  25. JXImageView *iv = [self createButton:self.subTitle drawTop:NO drawBottom:YES must:NO click:nil];
  26. iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
  27. _name = [self createTextField:iv default:nil hint:self.tip];
  28. [_name becomeFirstResponder];
  29. h+=iv.frame.size.height;
  30. h+=30;
  31. UIButton* _btn;
  32. _btn = [UIFactory createCommonButton:self.btnTitle target:self action:@selector(onSearch)];
  33. _btn.custom_acceptEventInterval = .25f;
  34. _btn.layer.masksToBounds = YES;
  35. _btn.layer.cornerRadius = 7.f;
  36. _btn.frame = CGRectMake(15, h, JX_SCREEN_WIDTH-30, 40);
  37. [self.tableBody addSubview:_btn];
  38. }
  39. - (void)onSearch {
  40. [self actionQuit];
  41. if ([self.delegate respondsToSelector:@selector(commonInputVCBtnActionWithVC:)]) {
  42. [self.delegate commonInputVCBtnActionWithVC:self];
  43. }
  44. }
  45. -(JXImageView*)createButton:(NSString*)title drawTop:(BOOL)drawTop drawBottom:(BOOL)drawBottom must:(BOOL)must click:(SEL)click{
  46. JXImageView* btn = [[JXImageView alloc] init];
  47. btn.backgroundColor = [UIColor whiteColor];
  48. btn.userInteractionEnabled = YES;
  49. btn.delegate = self;
  50. if(click)
  51. btn.didTouch = click;
  52. else
  53. btn.didTouch = @selector(hideKeyboard);
  54. [self.tableBody addSubview:btn];
  55. // [btn release];
  56. if(must){
  57. UILabel* p = [[UILabel alloc] initWithFrame:CGRectMake(INSETS, 5, 20, HEIGHT-5)];
  58. p.text = @"*";
  59. p.font = g_factory.font18;
  60. p.backgroundColor = [UIColor clearColor];
  61. p.textColor = [UIColor redColor];
  62. p.textAlignment = NSTextAlignmentCenter;
  63. [btn addSubview:p];
  64. // [p release];
  65. }
  66. JXLabel* p = [[JXLabel alloc] initWithFrame:CGRectMake(20, 0, JX_SCREEN_WIDTH/2-40, HEIGHT)];
  67. p.text = title;
  68. p.font = g_factory.font16;
  69. p.backgroundColor = [UIColor clearColor];
  70. p.textColor = [UIColor blackColor];
  71. [btn addSubview:p];
  72. // [p release];
  73. if(drawTop){
  74. UIView* line = [[UIView alloc] initWithFrame:CGRectMake(0,0,JX_SCREEN_WIDTH,LINE_WH)];
  75. line.backgroundColor = THE_LINE_COLOR;
  76. [btn addSubview:line];
  77. // [line release];
  78. }
  79. if(drawBottom){
  80. UIView* line = [[UIView alloc]initWithFrame:CGRectMake(0,HEIGHT-LINE_WH,JX_SCREEN_WIDTH,LINE_WH)];
  81. line.backgroundColor = THE_LINE_COLOR;
  82. [btn addSubview:line];
  83. // [line release];
  84. }
  85. if(click){
  86. UIImageView* iv;
  87. iv = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-15-7, (HEIGHT-13)/2, 7, 13)];
  88. iv.image = [UIImage imageNamed:@"new_icon_>"];
  89. [btn addSubview:iv];
  90. // [iv release];
  91. }
  92. return btn;
  93. }
  94. -(UITextField*)createTextField:(UIView*)parent default:(NSString*)s hint:(NSString*)hint{
  95. UITextField* p = [[UITextField alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH/2,INSETS,JX_SCREEN_WIDTH/2-15,HEIGHT-INSETS*2)];
  96. p.delegate = self;
  97. p.autocorrectionType = UITextAutocorrectionTypeNo;
  98. p.autocapitalizationType = UITextAutocapitalizationTypeNone;
  99. p.enablesReturnKeyAutomatically = YES;
  100. p.borderStyle = UITextBorderStyleNone;
  101. p.returnKeyType = UIReturnKeyDone;
  102. p.clearButtonMode = UITextFieldViewModeWhileEditing;
  103. p.textAlignment = NSTextAlignmentRight;
  104. p.userInteractionEnabled = YES;
  105. p.text = s;
  106. p.placeholder = hint;
  107. p.font = g_factory.font16;
  108. [parent addSubview:p];
  109. // [p release];
  110. return p;
  111. }
  112. /*
  113. #pragma mark - Navigation
  114. // In a storyboard-based application, you will often want to do a little preparation before navigation
  115. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  116. // Get the new view controller using [segue destinationViewController].
  117. // Pass the selected object to the new view controller.
  118. }
  119. */
  120. @end