显示文本的视图UILabel
UILabel继承于UIView 可以使用UIView里的方法
初始化
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100 , 100, 100, 200)];
设置属性 添加背景颜色
label.backgroundColor = [UIColor yellowColor];
1.添加字
label.text = @”Application windows are expected to have a root view “;
2.多行显示 完全显示 0 或 -1
label.numberOfLines = 0;
3.设置断行模式
label.lineBreakMode = NSLineBreakByTruncatingMiddle;
4.设置字体颜色
label.textColor = [UIColor blackColor];
5.设置字体对齐方式 右对齐
label.textAlignment = NSTextAlignmentRight;
6.获取系统的所有安装的字体
NSArray *fountArray = [UIFont familyNames];
NSLog(@”%@”,fountArray);
7.设置字体大小
label.font = [UIFont systemFontOfSize:15];
8.设置字体大小及字体类型
label.font = [UIFont fontWithName:@”Kohinoor Devanagari” size:40];
9.设置阴影颜色
label.shadowColor = [UIColor redColor];
10.调整阴影位置
label.shadowOffset = CGSizeMake(2, 1);
[self.window addSubview:label];
[label release];