UI基础之UITextField相关

UITextField *textF = [[UITextField alloc] init];

1、字体相关

    textF.text = @"文本框文字";
    textF.textColor = [UIColor blueColor];  // 字体颜色
    textF.textAlignment = NSTextAlignmentCenter;    // 文字对齐方式
    textF.font = [UIFont systemFontOfSize:13.0];    // 设置字体大小
    textF.font = [UIFont boldSystemFontOfSize:13.0];    // 设置加粗字体大小
    textF.font = [UIFont fontWithName:@"Arial" size:13.0];  // 设置字体样式及大小

2、边框

    textF.borderStyle = UITextBorderStyleRoundedRect;   // 边框样式

3、背景相关

    textF.backgroundColor = [UIColor whiteColor];   // 背景颜色
    textF.background = [UIImage imageNamed:@"a"];
    textF.disabledBackground = [UIImage imageNamed:@"b"];

4、清除按钮

    textF.clearButtonMode = UITextFieldViewModeWhileEditing;    // 当编辑时显示

5、占位文字

    textF.placeholder = @"占位文字";

6、光标相关

    textF.tintColor = [UIColor redColor];

7、文本安全性

    textF.secureTextEntry = YES;    // 文本安全性(用于密码显示)

8、清空文本框

    textF.clearsOnBeginEditing = YES;   // 再次编辑清空

9、键盘

    textF.keyboardType = UIKeyboardTypeNumberPad;   // 数字键盘

10、回车键样式

    textF.returnKeyType = UIReturnKeyDone;  // 确认

 

posted @ 2016-10-27 14:31  兔.小白  阅读(146)  评论(0编辑  收藏  举报