UI中的控件
这周我们学习了UI,下面是我的一些学习笔记:
//获得屏幕满屏时的数值
CGRectrect = [UIScreenmainScreen].bounds;
//创建一个Window让他显示在屏幕上
self.window= [[UIWindowalloc]initWithFrame:rect];
//设置window的背景颜色
self.window.backgroundColor= [UIColorlightGrayColor];
//把当前的window作为主window让它显示出来
[self.windowmakeKeyAndVisible];
/****************** UIButton***********************/
UIButton*button = [UIButtonbuttonWithType:UIButtonTypeCustom];
button.frame=CGRectMake(20,40,100,30);
//设置高亮状态下按钮的标题
[buttonsetTitle:@"按钮"forState:UIControlStateNormal];
//设置点击事件响应的方法
[buttonaddTarget:selfaction:@selector(butClick:)forControlEvents:UIControlEventTouchUpInside];
//设置平常状态下标题的颜色
[buttonsetTitleColor:[UIColorblackColor]forState:UIControlStateNormal];
//设置高亮状态下标题的颜色
[buttonsetTitleColor:[UIColorredColor]forState:UIControlStateHighlighted];
//设置标题的字体
button.titleLabel.font= [UIFontsystemFontOfSize:14];
//添加到window上
[self.windowaddSubview:button];
/******************** UITextField的常用属性*********************/
UITextField*textfield = [[UITextFieldalloc]initWithFrame:CGRectMake(200,200,100,25)];
//禁止首字母大写
textfield.autocapitalizationType=UITextAutocapitalizationTypeNone;
//设置键盘类型
textfield.keyboardType=UIKeyboardTypeNamePhonePad;
//输入框的边框类型
textfield.borderStyle=UITextBorderStyleRoundedRect;
//textfield.borderStyle = UITextBorderStyleLine;
//textfield.borderStyle = UITextBorderStyleBezel;
//textfield.borderStyle = UITextBorderStyleNone;
//设置委托代理模式
// textfield.delegate = self;
//键盘上得return按钮
textfield.returnKeyType=UIReturnKeyDone;
//是否安全输入,是的话,输入内容将为*号
textfield.secureTextEntry=NO;
//清除按钮模式
textfield.clearButtonMode=UITextFieldViewModeAlways;
//输入框中的文本颜色
textfield.textColor= [UIColorredColor];
//输入框的字体
textfield.font= [UIFontboldSystemFontOfSize:14];
//添加到window上
[self.windowaddSubview:textfield];
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。