textfield的属性
2015-08-17 08:30
330 查看
#pragma mark -textfield
- (void)_inittextfield
{
UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(100, 100, 180, 40)];
textField.tag = 200;
//背景颜色
textField.backgroundColor = [UIColor whiteColor];
//边框样式
// textField.borderStyle = UITextBorderStyleRoundedRect;
//输入的字体的大小
textField.font = [UIFont boldSystemFontOfSize:16];
//输入的字体的颜色
textField.textColor = [UIColor cyanColor];
//对齐方式
textField.textAlignment = NSTextAlignmentCenter;
//首字母自动大写
textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
//输入框为空时提示的文字
textField.placeholder = @"请输入内容";
//开启清除按钮
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
//成为第一响应者
[textField becomeFirstResponder];
[self.window addSubview:textField];
//create button
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
button1.backgroundColor = [UIColor greenColor];
button1.frame = CGRectMake(290, 100, 40, 40);
[button1 setTitle:@"^" forState:UIControlStateNormal];
//button1 click
[button1 addTarget:self action:@selector(button1Click) forControlEvents:UIControlEventTouchUpInside];
[self.window addSubview:button1];
}
- (void)button1Click
{
UITextField *textField = (UITextField *)[self.window viewWithTag:200];
[textField resignFirstResponder];
}
- (void)_inittextfield
{
UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(100, 100, 180, 40)];
textField.tag = 200;
//背景颜色
textField.backgroundColor = [UIColor whiteColor];
//边框样式
// textField.borderStyle = UITextBorderStyleRoundedRect;
//输入的字体的大小
textField.font = [UIFont boldSystemFontOfSize:16];
//输入的字体的颜色
textField.textColor = [UIColor cyanColor];
//对齐方式
textField.textAlignment = NSTextAlignmentCenter;
//首字母自动大写
textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
//输入框为空时提示的文字
textField.placeholder = @"请输入内容";
//开启清除按钮
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
//成为第一响应者
[textField becomeFirstResponder];
[self.window addSubview:textField];
//create button
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
button1.backgroundColor = [UIColor greenColor];
button1.frame = CGRectMake(290, 100, 40, 40);
[button1 setTitle:@"^" forState:UIControlStateNormal];
//button1 click
[button1 addTarget:self action:@selector(button1Click) forControlEvents:UIControlEventTouchUpInside];
[self.window addSubview:button1];
}
- (void)button1Click
{
UITextField *textField = (UITextField *)[self.window viewWithTag:200];
[textField resignFirstResponder];
}
相关文章推荐
- VB使用ADODB操作数据库
- 如何找出你性能最差的SQL Server查询
- 黑马程序员——集合(上)
- OpenGL 顶点数组的使用
- Win10 Mobile预览版越狱解锁 更多修改注册表实现效果出炉
- 单例(Singleton)模式
- OD使用之查找 API的方法之一
- block(闭包)
- 拓扑
- hdu 5385 The path 贪心?构造
- OC:通讯录实战
- Java用native2ascii命令做unicode编码转换
- c++学习重点分析
- mac删除顽固图标
- 互联网公司做智能硬件要注意什么?
- qt预编译 提高编译速度
- 强命名程序集,签名,延迟签名
- 解决问题E: 无法获得锁 /var/lib/dpkg/lock - open (11: 资源暂时不可用) E: 无法锁定管理目录
- java多线程(二)锁对象
- List的一阶函数操作代码实战详解之Scala学习笔记-24