文章标题
2015-11-18 11:59
330 查看
UITextField
注:在.h文件中声明UITextFieldDelegage
UITextField delegate
-UITextView
在.h文件中声明UITextViewDelegate
UITextView delegate
注:在.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; - }
相关文章推荐
- sql内置函数pivot强大的行转列功能
- DEELX 正则表达式扩展语法:递归表达式
- Win2D 官方文章系列翻译 - 与 Direct2D 互操作
- python--自动删除文件
- 状态模式(State Pattern)
- MySQL针对Discuz论坛程序的基本优化教程
- 利用scp 远程上传下载文件/文件夹
- TextView 添加链接
- .NET导出Excel遇到的错误的解决方法
- UIImageView图片视图的基本概念和使用方法
- python--自动删除文件
- mms
- PostgreSQL与MySQL比较(转)
- docker centos7 httpd的小坑
- 点击TextField禁止弹出键盘
- log4j配置详解
- ASPxGridView实现点击行则自动启用编辑状态
- 漂亮的checkbox
- 划分树
- mysql limit查询优化