我的iOS学习历程 - UITextField UIButton
2015-11-11 23:23
183 查看
UITextField
1.初始化UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(100, 100, 200, 50)];
2占位字 placeholder(只有当没有输入的字 才会显示)
textField.placeholder = @”请输入用户名”;
3 clearsOnBeginEditing
textField.clearsOnBeginEditing = YES;
4.是否允许输入 enabled(默认是YES:可以输入)
textField.enabled = YES;
5.密文输入 secureTextEntry
textField.secureTextEntry = YES;
6 弹出键盘的类型 keyboardType
textField.keyboardType = UIKeyboardTypeDefault;
7弹出键盘右下角return按钮 类型 returnKeyType
textField.returnKeyType = UIReturnKeyNext;
8自定义键盘 inputView(只有高度可以影响, 其他值不影响)
UIView *inputView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 100)];
9键盘辅助视图 inputAccessoryView
UIView *inputAccessoryView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
10边框样式 borderStyle
textField.borderStyle = UITextBorderStyleRoundedRect;
11删除按钮 何时存在 clearButtonMode(默认是用不出现的)
textField.clearButtonMode = UITextFieldViewModeUnlessEditing;
12输入框左视图 leftView(只有长度和高度可以影响)
UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
13左视图何时存在 leftViewMode
textField.leftViewMode = UITextFieldViewModeWhileEditing;
14输入框右视图 rightView
UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
15设置代理(方法在哪里实现的 就把谁设置为代理)
textField.delegate = self;
16实现协议中的方法(textFieldShouldReturn)
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
// 实现键盘回收(收回textField的第一响应者 点击哪个哪个就是第一响应者)
// 取消第一响应者 resignFirstResponder
[textField resignFirstResponder];
return YES;
}
UIButton
17初始化ButtonUIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
18设置某个状态下的标题 setTitle:NSString* forState:(UIControlState)
[button setTitle:@”普通” forState:(UIControlStateNormal)];
[button setTitle:@”高亮” forState:(UIControlStateHighlighted)];
[button setTitle:@”选中” forState:(UIControlStateSelected)];
19给Button添加一个方法 addTarget:self action:@selector(方法) forControlEvents:(UIControlEvents(点击状态))
[button addTarget:self action:@selector(buttonClick:)
20给某状态下的标题设置颜色
[button setTitleColor:[UIColor yellowColor] forState:(UIControlStateNormal)];
[button setTitleColor:[UIColor blueColor] forState:(UIControlStateHighlighted)];
[button setTitleColor:[UIColor greenColor] forState:(UIControlStateSelected)];
21.// 创建一张图片(如果不是png格式的图片 需要把后缀加上)
UIImage *imageNormal = [UIImage imageNamed:@”Normal”];
22 给Button添加前景图片(图多大就占多大 标题会被挤一边去)
[button setImage:(imageNormal) forState:(UIControlStateNormal)];
23.给Button添加背景图片
[button setBackgroundImage:imageNormal forState:(UIControlStateNormal
24给button 添加的方法
- (void)buttonClick:(UIButton *)button {
// 更改一下选中的状态
button.selected = !button.selected;
NSLog(@”你点我干嘛”);
}
相关文章推荐
- Quick小白书系列(四)Quick中的Scene
- 学习笔记-七burpsuite的使用
- [TwistedFate]UIButton 应用启动流程
- [TwistedFate]UITextField
- LeetCode Range Sum Query - Immutable
- IOS UIProgressView
- 系统自带的UIBarButtonSystemItem样式
- Spark RDD中Transformation的mapValues、subtract、sample、takeSample详解
- ps2015安装guideguide参考线辅助工具
- apue《UNIX环境高级编程第三版》第二章答案详解
- Leetcode153: Permutation Sequence
- NGUI ScrollView让Item居中显示.
- UI第二天:第⼆讲:基础视图、程序启动流程
- solr facet查询及solrj 读取facet数据【facet.prefix应用:搜索引擎拼写提示(也可用suggest);Solr 默认 requestHandler已包含 Facet 组件】
- EASYUI 树形菜单 fastjson JAVA嵌套对象转JSON
- requests的content与text导致lxml的解析问题
- request.getSession()和request.getSession(true/false)的理解
- muduo库阅读(33)——Net部分:定时器队列TimerQueue
- UITableViewEdit
- UITableView的一些方法