iOS(学习3) UITextField 常用属性
来源:互联网 发布:抢票的软件 编辑:程序博客网 时间:2024/06/04 01:02
#import “ViewController.h"//设置代理@interface ViewController ()<UITextFieldDelegate>{ UITextField *textField; UIButton *_button;}@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; //背景设置成白色 self.view.backgroundColor = [UIColor yellowColor]; //textField 在视图中的位置 textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 30, 300, 30)]; //设置边框样式 有圆角 白色背景 textField.borderStyle = UITextBorderStyleRoundedRect; //背景颜色 //textField.backgroundColor = [UIColor blueColor]; //提示文字 textField.placeholder = @"请输入密码"; //设置密文输入 textField.secureTextEntry = YES; //设置键盘样式 textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation; //键盘风格 半透明 /* UIKeyboardAppearanceLight //不透明 UIKeyboardAppearanceAlert //半透明 */ textField.keyboardAppearance = UIKeyboardAppearanceAlert; //设置弹出视图 比如自定义键盘 UIImageView *imageVeiw = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"11.jpg"]] ; imageVeiw.frame = CGRectMake(100, 10, 320, 220); //textField.inputView = imageVeiw; //左视图 .jpg格式 要带后缀名 png格式不用带后缀名 textField.leftView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"图片名字"]]; /* UITextFieldViewModeUnlessEditing //编辑是消失 UITextFieldViewModeAlways //从不消失 */ textField.leftViewMode = UITextFieldViewModeAlways; //清除按钮格式 textField.clearButtonMode = UITextFieldViewModeAlways; //再次编辑时 是否清空 textField.clearsOnBeginEditing = YES; //内容对齐方式 textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; //文本对齐方式 textField.textAlignment = NSTextAlignmentCenter; //滚动 textField.adjustsFontSizeToFitWidth = NO; //设置最小字号 textField.minimumFontSize = 20; //设置return健样式 textField.returnKeyType = UIReturnKeyGoogle; textField.delegate = self; UITextField *textField2 = [[UITextField alloc] initWithFrame:CGRectMake(10, 100, 300, 30)]; [self.view addSubview:textField2]; [self.view addSubview:textField]; _button = [UIButton buttonWithType:UIButtonTypeCustom]; _button.frame = CGRectMake(10, 450, 300, 30); [_button addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside]; _button.backgroundColor = [UIColor whiteColor]; [self.view addSubview:_button]; }//按钮点击方法- (void) buttonClick{ NSLog(@"haha");}- (void)keybarldWillShow{ [UIView animateWithDuration:0.20 animations:^{ _button.frame = CGRectMake(10, 250, 300, 30); }];}- (void)keybarldWillHhow{ [UIView animateWithDuration:0.20 animations:^{ _button.frame = CGRectMake(10, 450, 300, 30); }];}//点击屏幕收缩键盘- (void)controlAction{ [textField resignFirstResponder];}//文本输入框是否可以进入编辑模式- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{ NSLog(@"文本输入框是否可以进入编辑模式"); return YES;}//文本输入框已经进入编辑模式- (void)textFieldDidBeginEditing:(UITextField *)textField{ NSLog(@"文本输入框已经进入编辑模式");}//文本输入框是否可以退出编辑模式- (BOOL)textFieldShouldEndEditing:(UITextField *)textField{ NSLog(@"文本输入框是否可以退出编辑模式"); return YES;}//文本输入框已经退出编辑模式- (void)textFieldDidEndEditing:(UITextField *)textField{ NSLog(@"文本输入框已经退出编辑模式");}//文本输入框是否点击Retur按钮- (BOOL)textFieldShouldReturn:(UITextField *)textField{ [textField resignFirstResponder]; NSLog(@"文本输入框是否点击Retur按钮"); return YES;}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}@end
0 0
- iOS(学习3) UITextField 常用属性
- 【IOS开发】UITextField 常用属性
- iOS UITextField常用属性归纳
- ios学习笔记——UITextField常用属性及设置
- ios学习之 UITextField属性
- iOS开发之UITextField常用属性设置
- iOS开发之UITextField常用属性设置
- IOS学习 UITextField 属性和代理
- iOS之UI学习-UITextField属性篇
- UITextField 常用属性
- UITextfield常用属性
- UITextField常用属性设置
- UITextfield常用属性大全
- iOS开发3:UITextField控件的属性
- iOS开发3:UITextField控件的属性
- IOS基本控件常用属性及方法(五)---UITextField
- iOS开发总结之UITextField常用属性和方法
- iOS UITextField属性
- python核心编程-GUI程序之偏函数应用
- java 中println(this)的逻辑
- x265-1.7版本-common/scalinglist.cpp注释
- RHEL CENTOS ORACLE LINUX 7.x设置X11转发到XManager
- Linux---CentOS搭建环境之安装JDK
- iOS(学习3) UITextField 常用属性
- 队列的链式结构实现
- 从机广播本机的地址
- 第六天,UITableView,和cell的基础介绍
- perl post json
- Java开发中的23种设计模式详解
- x265-1.7版本-common/slice.cpp注释
- 01串多重比较
- Kali Linux 2016.1发布基于Debian的Linux发行版