UITextfield
2015-08-01 10:53
459 查看
UITextfield
先改为手动释放并把释放写完
给键盘添加一个辅助视图
回收键盘
先改为手动释放并把释放写完
//输入框 UITextField *textField = [ [UITextField alloc] initWithFrame:CGRectMake(100,100,100,40)]; textField.backgroundColor = [UIColor cyanColor]; [self.window addSubview:textField]; [textField release]; //边框,圆角,文本,透明度,文本字体 textField.layer.borderWidth = 1; textField.layer.cornerRadius = 10; textField.text = @""; textField.alpha = 0.5; textField.font = [UIFont systemFontOfSize:18]; //占位文本 textField.placeholder = @"请输入账号"; //使用圆点代替输入内容,在输入密码等不直接显示输入内容时可以把文本转换成圆点 (BOOL) textField.secureTextEntry = YES; //设置键盘格式(枚举类型,有多种形式) textField.keyboardType = UIReturnKeySearch; //文本运行时清空输入框内内容 textField.clearsOnBeginEditing = YES; //清除按钮样式(枚举类型) textField.clearButtonMode = UITextFieldViewModeAlways;
给键盘添加一个辅助视图
//先创建一个view UIView *view = [[UIView alloc]initWithFrame:CGRectMake(100, 200, 100, 100)]; //弹出一个自定义的视图,默认是键盘; textField.inputView; //给键盘添加一个辅助视图 textField.inputAcceddoryView = view;
回收键盘
//回收键盘需要签订UITextFieldDelegate协议,并设定代理人 //签订协议将UITextFieldDelegate加到.h中 //设置代理人 self.textField.delegate = self; //设置方法 - (BOOL)textFieldShouldReturn:(UITextField *)textField { //这句话是实现协议的关键 [ textField resignFirstResponder ]; return YES; }
相关文章推荐
- POJ 1679 The Unique MST
- UILabel
- 通过UIAlertView或者ActionSheet控件调用share方法
- UIView
- poj 1019 Number Sequence 【组合数学+数字x的位宽函数】
- UITableViewCell 输入框动态变高
- Ueditor上传图片到本地改造到上传图片到云存储
- 随机生成UUID的工具类
- iOS开发UI篇—transframe属性(形变)
- Serializable serialVersionUID
- UIViewController 视图控制器
- UIButton,UITextField
- [LeetCode]232.Implement Queue using Stacks
- uva-133 - The Dole Queue
- iOS UI03_UIViewController视图控制器
- iOS UI03_LTView
- 写在Demo战斗系统之前,先用原型工具做套UI第四篇-回合制战斗UI界面制作
- 【LeetCode-面试算法经典-Java实现】【063-Unique Paths II(唯一路径问题II)】
- 【LeetCode-面试算法经典-Java实现】【062-Unique Paths(唯一路径)】
- UI常用字体定义和继承的实例,ResearchKitCode