UITextField 和 UIButton的基本属性和用法

来源:互联网 发布:mac电磁阀中国有限公司 编辑:程序博客网 时间:2024/05/22 12:13
UITextField

placeholder  //占位字符
font= [UIFontsystemFontOfSize:20];// 字体
clearButtonMode//清除按钮显示
{
    UITextFieldViewModeNever, //不显示
    UITextFieldViewModeWhileEditing,//编辑时显示
    UITextFieldViewModeUnlessEditing,//编辑时不显示
    UITextFieldViewModeAlways//一直显示
}
keyboardType//键盘类型
{
 UIKeyboardTypeDefault,    //默认键盘            
 UIKeyboardTypeASCIICapable,           
 UIKeyboardTypeNumbersAndPunctuation,  
 UIKeyboardTypeURL,                  
 UIKeyboardTypeNumberPad,     //数字键盘         
 UIKeyboardTypePhonePad,      //电话键盘         
 UIKeyboardTypeNamePhonePad,      
 UIKeyboardTypeEmailAddress,
}
borderStyle://边框类型
{
    UITextBorderStyleNone,//没有边框
    UITextBorderStyleLine,//黑线直角
    UITextBorderStyleBezel,//细线
    UITextBorderStyle

returnKeyType //右下角return键样式
{
 UIReturnKeyDefault,
    UIReturnKeyGo,
    UIReturnKeyGoogle,
    UIReturnKeyJoin,
    UIReturnKeyNext,
    UIReturnKeyRoute,
    UIReturnKeySearch,
    UIReturnKeySend,
    UIReturnKeyYahoo,
    UIReturnKeyDone,
    UIReturnKeyEmergencyCall,
}
 
- (BOOL)becomeFirstResponder;//成为第一响应者
- (BOOL)resignFirstResponder;// 取消第一响应者
- (BOOL)isFirstResponder;//是否为第一响应者

delegate //代理
clearsOnBeginEditing //再次编辑时清空输入框 (YES ,  NO);
secureTextEntry //是否以密码点显示
//点击右下角return的实现
- (BOOL)textFieldShouldReturn:(UITextField*)textField

UITextField
//创建一个button
//注意!类方法创建对象不用手动管理内存
UIButton *button = [UIButtonbuttonWithType:UIButtonTypeCustom];
button.frame= CGRectMake(100,100,36,36);
button.tag= 100;//标签
button.backgroundColor= [UIColorredColor];//颜色
[buttonsetTitle:@"按钮"forState:UIControlStateNormal];//添加标题
{
forState //状态
UIControlStateNormal //正常
UIControlStateHighlighted //高亮
UIControlStateSelected //选中
}
//button加标题颜色(不同状态下)
[buttonsetTitleColor:[UIColorblueColor] forState:UIControlStateNormal];
[ button.layersetCornerRadius: 10]给button添加边框圆角
//button添加实现
    [buttonaddTarget:selfaction:@selector(buttonClick:)//方法名 forControlEvents:UIControlEventTouchUpInside];
//给button添加图片
setImage:<#(UIImage *)#> forState:<#(UIControlState)#>

0 0
原创粉丝点击