UITextField

2016-09-16  本文已影响14人  liwendong

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {

[super viewDidLoad];

//任务:

//1.创建输入框,在屏幕中心, 宽度比屏幕小100

UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width - 100, 40)];

[self.view addSubview:tf];

tf.center = self.view.center;

//2.文字颜色 蓝色

tf.textColor = [UIColor blueColor];

//3.字体大小 18号

tf.font = [UIFont systemFontOfSize:18];

//4.排版居右

tf.textAlignment = NSTextAlignmentRight;

//5.默认输入提示: 请输入密码

tf.placeholder = @"请输入密码";

//6.清空内容按钮, 在编辑时出现, 默认的也是这样。

tf.clearButtonMode = UITextFieldViewModeWhileEditing;

//7.键盘类型: 纯英文+符号

tf.keyboardType = UIKeyboardTypeASCIICapable;

//8.键盘样式: 黑色

tf.keyboardAppearance = UIKeyboardAppearanceDark;

//9.返回按钮: GO  默认的为return.

tf.returnKeyType = UIReturnKeyGo;

//10.内容为密文    默认的为可见的。

tf.secureTextEntry = YES;

//11.边框风格是 Line(线性的,上面的一条线细一点)风格(2.Bezel(有边框的,有灰色阴影),3.None(没有边框的) 4. RoundedRect(圆角的)。

tf.borderStyle = UITextBorderStyleLine;

}

- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

@end

上一篇下一篇

猜你喜欢

热点阅读