你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> UITextField對象的手工創建

UITextField對象的手工創建

編輯:IOS開發綜合
1.UITextField的初始化和設置   UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 200, 300, 40)]; textField.borderStyle = UITextBorderStyleRoundedRect; textField.font = [UIFont systemFontOfSize:15]; textField.placeholder = @"enter text"; textField.autocorrectionType = UITextAutocorrectionTypeNo; textField.keyboardType = UIKeyboardTypeDefault; textField.returnKeyType = UIReturnKeyDone; textField.clearButtonMode = UITextFieldViewModeWhileEditing; textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;     textField.delegate = self; [self.view addSubview:textField]; [textField release];   2.要實現的Delegate方法,打開或關閉鍵盤   顯示keyboard: [textField becomeFirstResponder]; - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {     [textField becomeFirstResponder];     return YES; }   隱藏keyboard [textField resignFirstResponder];   - (BOOL)textFieldShouldReturn:(UITextField *)textField {     [textField resignFirstResponder];     return YES; }
  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved