----------UILabel知识点------------
//1.创建UILabel对象
UILabel*label =[[UILabelalloc]initWithFrame:CGRectMake(10,30,300,60)];
//2.配置UILabel的属性
//2.1配置背景颜色
[label setBackgroundColor:[UIColorcyanColor]];
//2.2设置显示的文字
label.text=@"欢迎进入QQ登录界面";
//2.3设置文字的颜色
label.textColor= [UIColorredColor];
//2.4设置文本居中
label.textAlignment=NSTextAlignmentCenter;
//2.5设置文字大小
label.font= [UIFontsystemFontOfSize:30];
//字体采用加粗的字体样式
label.font= [UIFontboldSystemFontOfSize:25];
//UIFont是一个字体
//遍历系统中可以使用字体名称
for (NSString *name in [UIFont familyNames]){
NSLog(@"%@",name);
}
label.font = [UIFont fontWithName:@"Marion"size:25];
//2.6设置文本的行数
label.numberOfLines=0;//设置为0,表示不限制行数,默认为1行
//2.7行数的截取方式
//NSLineBreakByWordWrapping = 0,
//NSLineBreakByClipping,
//NSLineBreakByTruncatingHead,
//NSLineBreakByTruncatingTail
//NSLineBreakByTruncatingMiddle
//常用为以下两个
//NSLineBreakByWordWrapping通过单词截取
//NSLineBreakByCharWrapping 通过字符截取
label.lineBreakMode=NSLineBreakByWordWrapping;
//2.8设置阴影颜色
label.shadowColor= [UIColorblackColor];
//2.9阴影的偏移量
label.shadowOffset=CGSizeMake(1,2);
//2.10设置文本的对齐方式
label.textAlignment=NSTextAlignmentCenter;
//NSTextAlignmentLeft 左对齐
//NSTextAlignmentRight 右对齐
//NSTextAlignmentCenter 居中对齐
//2.11切圆角,下面两个同时才能显示
label.
layer.cornerRadius=10;//切圆角
label.layer.masksToBounds=YES;
//3.添加到父视图
[contentView addSubview:label];
[label release];
----------UITextField知识点------------
//1.创建UITextField对象
UITextField*textField =[[UITextFieldalloc]initWithFrame:CGRectMake(80,200,200,30)];
//2.配置属性
//shift + command +k收回和放出键盘
textField.backgroundColor= [UIColorwhiteColor];
//文本框类型
textField.borderStyle=UITextBorderStyleRoundedRect;
//2.2设置文本框的提示文字
textField.placeholder=@"请输入账号";
//2.3设置输入框文本
textField.text=@"12345";
//2.4设置输入文本颜色,只影响输入框输入文本的颜色
textField.textColor= [UIColorredColor];
//2.5设置文本框的对齐格式
textField.textAlignment=NSTextAlignmentLeft;
//2.6设置文本输入框的是否可编辑
// textField.enabled = NO;//默认可编辑YES;
//关闭用户交互
// textField.userInteractionEnabled = NO;
//2.7当文本输入框开始输入的时候,清空输入框中的内容,默认为NO,只在第一个起作用
textField.clearsOnBeginEditing=YES;
//2.8设置键盘弹出格式
textField.keyboardType=UIKeyboardTypeNumberPad;
textField.keyboardType=UIKeyboardTypeNumbersAndPunctuation;
//2.9设置return键的格式
textField.returnKeyType=UIReturnKeyDone;
//2.10设置文本输入框是否以加密的形式显示,默认是NO;
textField.secureTextEntry=YES;
//3.添加到父视图
[contentView addSubview:textField];
//4.释放所有权
[textFieldrelease];
[contentViewrelease];
// Override point forcustomization after application launch.
self.window.backgroundColor= [UIColorwhiteColor];
[self.windowmakeKeyAndVisible];
returnYES;
}
----------UIButton知识点------------
//UIButton是iOS中用来相应点击事件的控制,是UIControl的子类
//1.创建UIButton对象
UIButton*button =[UIButtonbuttonWithType:(UIButtonTypeCustom)];
//UIButtonTypeDetailDisclosure 详细信息(浅色背景)
//UIButtonTypeInfoDark 详细信息(深色背景)
//UIButtonTypeInfoLight 详细信息(浅色背景)
//UIButtonTypeSystem 系统样式
//UIButtonTypeContactAdd 加号按钮
//UIButtonTypeCustom 自定义格式,需要添加图片的时候需要使用此种类型
//2.配置属性
button.backgroundColor=[UIColorgreenColor];
//2.2设置button的frame
button.frame=CGRectMake(10,300,300,60);
//2.3给button切圆角
button.layer.cornerRadius=15;
//2.4给button添加标题
//注意:给button添加标题时一定要写清楚状态
[buttonsetTitle:@"正常状态" forState:UIControlStateNormal];
[buttonsetTitle:@"高亮状态" forState:UIControlStateHighlighted];
[button setTitle:@"不可用状态"forState:UIControlStateDisabled];
[button setTitle:@"选中状态"forState:UIControlStateSelected];
//2.5设置button是否可用
//默认是可用状态YES;
// button.enabled = NO;
//2.6 设置button是否处于选中状态
//默认是处于没有选中状态NO,设置为YES处于选中状态
button.selected=NO;
//2.7设置button上标题的文字大小
//button是一个复合视图(有多个视图构成的视图),其中titleLable是标题,用来显示标题,还有一个imageView,用来显示图片
button.titleLabel.font=[UIFontboldSystemFontOfSize:20];
//2.8设置button标题的颜色
button.tintColor=[UIColorredColor];
//2.9设置button的imageView的图片
//UIImage是一个图片类,继承自NSObject
//创建UIImage对象
// UIImage *image = [UIImage imageNamed:@"1"];//只有png格式后缀的图片不写后缀,其他的都要写后缀
//
// [button setImage:image forState:UIControlStateNormal];
//2.10设置button背景图片
//3.添加到父视图上
[self.windowaddSubview:button];
UIImage*image2 =[UIImageimageNamed:@"2.jpg"];
[button setBackgroundImage:image2forState:UIControlStateNormal];
UIImage*image3 =[UIImageimageNamed:@"3.jpg"];
[button setBackgroundImage:image3forState:UIControlStateHighlighted];
//buttond的关联时间
//Target:button指定的响应的对象
//action :指定相应对象调用的方法,方法用来处理button点击事件
//ControlEvents:事件的触发时机,一般用UIControlEventTouchUpInside
[buttonaddTarget:selfaction:@selector(handleAction:)forControlEvents:UIControlEventTouchUpInside];//方法有参数handleAction:加冒号
[contentViewrelease];
//Override point for customization after applicationlaunch.
self.window.backgroundColor=[UIColorwhiteColor];
[self.windowmakeKeyAndVisible];
returnYES;
}
//botton点击事件的实现方法
-(void)handleAction:(UIButton*)button{
NSLog(@"鼓掌");
}