您的位置:首页 > 其它

文章标题

2015-11-18 11:59 330 查看
UITextField

注:在.h文件中声明UITextFieldDelegage

UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 74, self.view.frame.size.width - 20, 31)];
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.placeholder = @"...";
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
textField.secureTextEntry = YES;
textField.keyboardType = UIKeyboardTypeEmailAddress;
textField.returnKeyType = UIReturnKeyGo;
textField.textColor = [UIColor cyanColor];
textField.font = [UIFont boldSystemFontOfSize:16.0f];
textField.delegate = self;
textField.contentVerticalAlignment = UIViewContentModeCenter;
[self.view addSubview:textField];


UITextField delegate

- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
- {
- return Yes;
- }

- (void)textFieldDidEndEditing:(UITextField *)textField
- {
- }

- (BOOL)textFieldShouldReturn:(UITextField *)textField
- {
- [textField resignFirstResponder];
- return YES;
- }


-UITextView

在.h文件中声明UITextViewDelegate

UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(x, y, width, height)];
textView.backgroundColor = [UIColor redColor];
textView.textColor = [UIColor blackColor];
textView.keyboardType = UIKeyboardTypeEmailAddress;
textView.returnKeyType = UIReturnKeyGo;
textView.delegate = self;
[self.view addSubview:textView];


UITextView delegate

- (void)textViewDidEndEditing:(UITextView *)textView
- {
-
- }

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
- {
- if (text isEqualToString:@"n"]) {
- [textView resignFirstResponder];
- return NO;
- }
- return YES;
- }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: