UITextField *t1 = [[UITextField alloc] initWithFrame:CGRectMake(150, 150, 130, 40)];
t1.placeholder = @"enter your name"; //在没有文字的时候显示提醒用户输入内容
t1.backgroundColor = [UIColor grayColor];
// 当输入框存在颜色的时候textfield不显示placeholder
// 外框类型
// t1.borderStyle = UITextBorderStyleRoundedRect;
// t1.borderStyle = UITextBorderStyleBezel;
// t1.borderStyle = UITextBorderStyleLine;
// t1.borderStyle = UITextBorderStyleNone;
// t1.secureTextEntry = YES; //隐藏输入信息
t1.textColor = [UIColor blackColor];
[_window addSubview:t1];
// //再次编辑就清空
// t1.clearsOnBeginEditing = YES;
// 右侧的清除按钮出现的时间
// t1.clearButtonMode = UITextFieldViewModeAlways;
// t1.clearButtonMode = UITextFieldViewModeNever;
// t1.clearButtonMode = UITextFieldViewModeUnlessEditing;
// t1.clearButtonMode = UITextFieldViewModeWhileEditing;
// //内容对齐方式
// text.textAlignment = UITextAlignmentLeft;
//
// //内容的垂直对齐方式 UITextField继承自UIControl,此类中有一个属性contentVerticalAlignment
// text.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
//
// //设置为YES时文本会自动缩小以适应文本窗口大小.默认是保持原来大小,而让长文本滚动
// textFied.adjustsFontSizeToFitWidth = YES;
//
// //设置自动缩小显示的最小字体大小
// text.minimumFontSize = 20;
//
// //设置键盘的样式
// t1.keyboardType = UIKeyboardTypeTwitter;
//
// typedef enum {
// UIKeyboardTypeDefault, 默认键盘,支持所有字符
// UIKeyboardTypeASCIICapable, 支持ASCII的默认键盘
// UIKeyboardTypeNumbersAndPunctuation, 标准电话键盘,支持+*#字符
// UIKeyboardTypeURL, URL键盘,支持.com按钮 只支持URL字符
// UIKeyboardTypeNumberPad, 数字键盘
// UIKeyboardTypePhonePad, 电话键盘
// UIKeyboardTypeNamePhonePad, 电话键盘,也支持输入人名
// UIKeyboardTypeEmailAddress, 用于输入电子 邮件地址的键盘
// UIKeyboardTypeDecimalPad, 数字键盘 有数字和小数点
// UIKeyboardTypeTwitter, 优化的键盘,方便输入@、#字符
// UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable,
// } UIKeyboardType;
//首字母是否大写
// text.autocapitalizationType = UITextAutocapitalizationTypeNone;
//
// typedef enum {
// UITextAutocapitalizationTypeNone, 不自动大写
// UITextAutocapitalizationTypeWords, 单词首字母大写
// UITextAutocapitalizationTypeSentences, 句子的首字母大写
// UITextAutocapitalizationTypeAllCharacters, 所有字母都大写
// } UITextAutocapitalizationType;
//
// //return键变成什么键
// text.returnKeyType =UIReturnKeyDone;
//
// typedef enum {
// UIReturnKeyDefault, 默认 灰色按钮,标有Return
// UIReturnKeyGo, 标有Go的蓝色按钮
// UIReturnKeyGoogle,标有Google的蓝色按钮,用语搜索
// UIReturnKeyJoin,标有Join的蓝色按钮
// UIReturnKeyNext,标有Next的蓝色按钮
// UIReturnKeyRoute,标有Route的蓝色按钮
// UIReturnKeySearch,标有Search的蓝色按钮
// UIReturnKeySend,标有Send的蓝色按钮
// UIReturnKeyYahoo,标有Yahoo的蓝色按钮
// UIReturnKeyYahoo,标有Yahoo的蓝色按钮
// UIReturnKeyEmergencyCall, 紧急呼叫按钮
// } UIReturnKeyType;
//键盘外观
// textView.keyboardAppearance=UIKeyboardAppearanceDefault;
// typedef enum {
// UIKeyboardAppearanceDefault, 默认外观,浅灰色
// UIKeyboardAppearanceAlert, 深灰 石墨色
//
// } UIReturnKeyType;
//最右侧加图片是以下代码 左侧类似
// UIImageView *image=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"right.png"]];
// text.rightView=image;
// text.rightViewMode = UITextFieldViewModeAlways;
//
// typedef enum {
// UITextFieldViewModeNever,
// UITextFieldViewModeWhileEditing,
// UITextFieldViewModeUnlessEditing,
// UITextFieldViewModeAlways
// } UITextFieldViewMode;
// UIButton 按钮
// 创建按钮与其他控件的区别在于按钮多数使用便利构造器进行初始化
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
//按钮使用便利构造器初始化不需要管理引用计数
button.frame = CGRectMake(50, 200, 60, 40);
//设置标记
button.tag = 1;
// 设置frame
button.backgroundColor = [UIColor cyanColor];
[_window addSubview:button];
// state:枚举类型表示在什么状态下设置文字
[button setTitle:@"登陆" forState:UIControlStateNormal];
[button setTitle:@"啊啊" forState:UIControlStateHighlighted];
//设置按钮字体
button.titleLabel.font = [UIFont systemFontOfSize:28];
// 按钮默认为蓝色
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[button setTitleShadowColor:[UIColor yellowColor] forState:UIControlStateHighlighted];
// 添加点击事件:按钮只能按一次
// 参数1:执行方法的对象(self)
// 参数2:参数1执行的方法
// 参数3:按钮触发的事件
[button addTarget:self action:@selector(buttonDidPress:) forControlEvents:UIControlEventTouchUpInside];