UItextField的用法

修改placehoder的颜色:

[ self.loginnameText setValue:[UIColor colorWithRed:184.f/255 green:214.f/255 blue:225.f/255 alpha:1] forKeyPath:@"_placeholderLabel.textColor"];

[ self.passwordText setValue:[UIColor colorWithRed:184.f/255 green:214.f/255 blue:225.f/255 alpha:1] forKeyPath:@"_placeholderLabel.textColor"];

改变键盘类型:

self.loginnameText.returnKeyType = UIReturnKeyNext;

self.passwordText.returnKeyType = UIReturnKeyGo;

给左右两边添加View:

_clearRightButton = [UIButton buttonWithType:UIButtonTypeCustom];

[_clearRightButton setFrame:CGRectMake(0, 0, 20, 20)];

[_clearRightButton setBackgroundImage:[UIImage imageNamed:@"cha"] forState:UIControlStateNormal];

[_clearRightButton addTarget:self action:@selector(clearLoginName) forControlEvents:UIControlEventTouchUpInside];

_clearRightButtonR = [UIButton buttonWithType:UIButtonTypeCustom];

[_clearRightButtonR setFrame:CGRectMake(0, 0, 20, 20)];

[_clearRightButtonR setBackgroundImage:[UIImage imageNamed:@"cha"] forState:UIControlStateNormal];

[_clearRightButtonR addTarget:self action:@selector(clearPassWord) forControlEvents:UIControlEventTouchUpInside];

self.loginnameText.rightView =_clearRightButton;

self.loginnameText.rightViewMode=UITextFieldViewModeWhileEditing;

self.passwordText.rightView =_clearRightButtonR;

self.passwordText.rightViewMode=UITextFieldViewModeWhileEditing;

时间: 2024-08-10 13:51:10

UItextField的用法的相关文章

UITextField常见用法

//实例变量和全局变量的区别 //1.定义位置有区别:全局变量定义在方法的外部,实例变量写在接口文件或者延展中的大括号之内 //2.生命周期:全局变量生命周期和应用程序生命周期相同,实例变量的生命周期依托于对象,有对象才会有空间,生命周期开始,对象销毁,生命周期结束. //3.可见度:全局变量全局都可以访问.实例变量,实例方法可以用. //UITextField是iOS中,用来输入文字的控件,比UILabel多了文字编辑的功能,是UIControl的子类,而UIControl是UIView的子类

swift - UITextField 的用法

1,文本框的创建,有如下几个样式: UITextBorderStyle.None:无边框 UITextBorderStyle.Line:直线边框 UITextBorderStyle.RoundedRect:圆角矩形边框 UITextBorderStyle.Bezel:边线+阴影 1 2 3 4 let textField = UITextField(frame: CGRectMake(10,160,200,30)) //设置边框样式为圆角矩形 textField.borderStyle = UI

IOS开发-UI学习-UITextField的具体属性及用法

直接上代码,里面有各种属性的用法注释,至于每个属性有多个可以设置的值,每个值的效果如何,可以通过查看这个函数参数的枚举量,并逐一测试. 1 //制作登陆界面 2 #import "ViewController.h" 3 4 @interface ViewController (){ 5 6 //定义全局变量(控件) 7 UITextField *username; 8 UITextField *password; 9 UIButton *resignbutton; 10 UIButto

XCODE UITextField 中的属性和用法

XCODE  UITextField  中的属性和用法 一些基本的用法 UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; CGRect frame =CGRectMake(110, 100, 100, 30); button.frame = frame; button.backgroundColor = [UIColor purpleColor]; [button setTitle:@"command&qu

iOS开发系列之三 - UITextField 用法小结

// 初始化输入框并设置位置和大小 UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 100, 300, 30)]; // 设置输入框提示 textField.placeholder = @"TextField Tip"; // 输入框中预先输入的文字 textField.text = @"预先输入的文字"; // 设置输入框文本的字体 textField.font

Swift—UITextField的基本用法

https://www.jianshu.com/p/63bdeca39ddf 1.文本输入框的创建##### let textField = UITextField(frame: CGRect(x:10, y:60, width:200, height:30)) // let textField = UITextField() // textField.frame = CGRect(x:20,y:30,width:100,height:30) //设置边框样式为圆角矩形 textField.bo

iOS UITextField的基本用法

UITextField *textField = [[UITextField alloc] init];//初始化 textField.userInteractionEnabled = YES;//是否可用 textField.text = @"UITextField"; //文字 textField.delegate = self; //代理 textField.frame = CGRectMake(100, 100, 100, 40); //大小和位置 textField.text

UITextField 用法

//初始化textfield并设置位置及大小 UITextField *text = [[UITextField alloc]initWithFrame:CGRectMake(20, 20, 130, 30)]; //设置边框样式,只有设置了才会显示边框样式 text.borderStyle = UITextBorderStyleRoundedRect; typedef enum { UITextBorderStyleNone, UITextBorderStyleLine, UITextBord

UITextField,常见属性的罗列和用法

UITextField是UIControl的子类 ,属于控件类(因为它有能力响应一些高级事件),在故事版中可以直接拖拽过来使用. 首先定义 UITextField *name; name = [[UITextField alloc]initWithFrame:CGRectMake(30, 70, 260, 60)];//创建一个文本框并初始化,为了方便在这里一块定义了Frame属性 name.borderStyle = UITextBorderStyleRoundedRect;//设置文本框的风