Button和Textfield 及其控件
来源:互联网 发布:知识竞赛软件免费版 编辑:程序博客网 时间:2024/05/18 03:37
@interfaceAppDelegate ()
@property(nonatomic,retain)UITextField *textField;(因为textField在方法和程序中都要用到所以定义这个类)
@property(nonatomic,assign)BOOL isClick;// (4).
@property(nonatomic,retain)UILabel *label;// (10).
点击按钮看到对应的文本
(1).创建按钮
UIButton *button = [UIButtonbuttonWithType:UIButtonTypeSystem];
button.frame =CGRectMake(150,300, 100,40);
button.backgroundColor = [UIColoryellowColor];
button.layer.borderWidth =1;
button.layer.cornerRadius =10;
[buttonsetTitle:@"测试"forState:UIControlStateNormal];
[self.windowaddSubview:button];
调用输出文本的方法
[buttonaddTarget:selfaction:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
(2).创建文本
self.textField = [[UITextFieldalloc] initWithFrame:CGRectMake(200,100, 100,40)];
self.textField.layer.borderWidth = 1;
self.textField.layer.cornerRadius = 10;
[self.windowaddSubview:self.textField];
[_textFieldrelease];
(3).设置输入进去之后是圆点(输入密码)
self.textField.secureTextEntry = YES;
(4).给textField添加addTarget-action方法(即时打印方法)
[self.textFieldaddTarget:selfaction:@selector(changeValue:)forControlEvents:UIControlEventEditingChanged];
(5).创建Label
self.label = [[UILabelalloc] initWithFrame:CGRectMake(100,400, 150,40)];
self.label.backgroundColor = [UIColorcyanColor];
[self.windowaddSubview:self.label];
[_labelrelease];
addTarget-action方法(即时打印方法)
- (void)changeValue:(UITextField *)textField
{
NSLog(@"%@", textField.text);
if (textField.text.length >5) {
self.label.text =@"密码长度可以";
} else {
self.label.text =@"密码长度过短";
}
}
切换图片的方法
- (void)changePic:(UIButton *)button
{
if (self.isClick) {
[button setImage:[UIImageimageNamed:@"checked.png"]forState:UIControlStateNormal];
} else {
[button setImage:[UIImageimageNamed:@"check.png"]forState:UIControlStateNormal];
setBackgroundImage会将图片填充满边框(无论原来的图片有多大)
setImage只是原图片的大小
}
self.isClick = !self.isClick;
self.textField.secureTextEntry = !self.textField.secureTextEntry;圆点与非圆点的循环
}
输出文本的方法
- (void)click:(UIButton *)button
{
NSLog(@"%@",self.textField.text);
}
- Button和Textfield 及其控件
- Label Button和textfield组合
- 用Button连接TextField和Label
- 1、Button、Label和Textfield的交互
- Cocos2dx控件 Text和TextField
- IOS学习四:基础控件Label,textfield,button等使用
- Button和ImageButton控件
- Button控件和RepeatButton控件
- button、dateField、textField
- Xcode控件使用笔记一:label、Button、slider 、switch、imageView、toolBar、TextField
- label textField button 一些用法
- 21.View,Label,Button,TextField
- COCOS学习笔记--Button类及其相关控件属性
- iOS中TextField 和 TextView 控件的基本使用
- Unity3D入门——GUI之TextField和PasswordField控件
- 键盘覆盖控件textfield
- IOS 控件 UITextField textField
- UI-控件-TextField
- WI-FI定位算法原理与介绍
- hal的调试基础
- OC语言__实现中等难度通讯录
- 在CentOS 6.0 安装R语言
- Java --------百思不得其解
- Button和Textfield 及其控件
- 既然抓不住,何不送一程!(一篇让数万人开悟的文章)
- 枚举定义的两种方法
- 查询技术
- iOS 判断GPS是否开启
- mysql 解决数据库连接变慢
- cocos2dx之商店源码
- Linux 下的 CONFIG_OF 选项
- Oracle中merge into的使用