1.今日任务,文本输入框,textfiled.
2按钮 uibutton,
3.代理在UI中的使用。
4.应用程序的启动流程
1.textfiled 就是文本输入框,
第一类,是文本控制,
(1)borderStyle 文本框类型UItextBoardStyle
(2)输入提示 placeholder
(3)默认值 .text
(4)设置文本颜色 Textcolor,对齐方式 字体大小。
第二类 输入控制
(1) .enable 设置输入框是否可用 .enable=YES;
(2) .keyboardType 键盘的类型UIkeyboardTypeASCIICapale
(3) .returnKeyType 设置returnkey的按钮的样式,右下角。
(4) .clearsOnBeginEditing =YES ,当开始输入内容的时候,清楚输入框中的所有内容
(5) .secureTextEntry =YES ,设置文字为安全样式。
(6) 在UI开发中,只要参数是UI view类型的,就是标志着这里可以传进去任意类型的控件,
(7)添加辅助视图:在输入键盘位置的上方预览输出信息。结合下个属性
UIView *fview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 300, 50)];
fview.backgroundColor=[UIColor grayColor];
f1.inputAccessoryView=fview;
(8) 添加子视图,在点击父视图,可以覆盖键盘,实现键盘的重写。
UIView *mview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 300, 200)];
mview.backgroundColor=[UIColor greenColor];
f1.inputView=mview;
第三类界面:
(1) 设置边框样式。 borderStyle 文本框类型UItextBoardStyle
(2) 设置清除按钮的样式,永久,编辑时显示,输入前有,默认是Never从不显示。
f1.clearButtonMode=UITextFieldViewModeAlways;
(3) 左右view,添加提示或备注的时候,注意成对使 用,先model为always
f1.leftViewMode=UITextFieldViewModeAlways; f1.leftView=leftview;
1)注意左右视图会挤占textFiled的使用空间,再添加左右视图的时候,计算大小,适当增加俯视图的长度。
2.UIbutton 按钮控件
(1)在创建button的时候指定button的类型,
(2)设置不同状态下的按钮的标题 [button setTitle:@"登陆" forState:UIControlStateNormal];
[button setTitle:@"哈hahahhaahahh" forState:UIControlStateHighlighted];
(3)设置按钮标题的颜色 [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
(4)设置按钮的背景颜色 button.backgroundColor=[UIColor grayColor];
(5)设置按钮的圆角形状:
button.layer.masksToBounds=YES;
button.layer.cornerRadius=10.0;
(6) 添加响应事件: [button addTarget:self action:@selector(action:) forControlEvents:UIControlEventTouchUpInside];
(7) 移除响应事件 [self.butten removeTarget:self action:@selector(action:)
forControlEvents:UIControlEventTouchUpInside];
3.设置图片:
UIImage *ima=[UIImage imageNamed:@"1.png"];
(1) [self.butten setBackgroundImage:ima forState:UIControlStateNormal];
(2) [_butten setImage:ima forState:UIControlStateNormal];
4.代理:当把一个textFiled注销第一响应者,那么键盘就会被回收。
(1)代理的实现:
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return YES;
5.扩充:
6.应用程序的启动流程
(1)main函数中的一行代码,实现了3个功能,1)创建一个应用程序,2)创建一个应用程序代理实例,3)建立循环监听
原文:http://www.cnblogs.com/ytmaylover/p/5049214.html