1.UILabel初始化

UILabel *userNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(30, 100, 100, 30)];

userNameLabel.text = @"用户名";

[containerView addSubview:userNameLabel];

[userNameLabel release];

2.UILabel基本属性

2.1 文本属性

text:label显示的文本                               label.text = @“用户名”;

textColor:文本内容的颜色                         label.textColor = [UIColor redColor] ;

textAlignment: 文本对齐方式(水平方向)  label.textAlignment = NSTextAlignmentLeft; (左对齐)

font: 文本字体                                              label.font = [UIFont fontWithName:@“Helvetica-Bold” size:20];

numberOfLines: 行数                                  label.numberOfLines = 3 ,没显示完的用省略号代理

lineBreakMode:  断行模式                           label.lineBreakMode = NSLineBreakByWordWrapping,以单词为单位                                                                     换行

2.2标签样式

clipsToBounds:修剪视图边框,才剪掉超出父视图边框的部分,默认为NO

 label.clipsToBounds = YES; 此方法可用于修改标签圆角

shadowColor: 阴影颜色                            label.shadowColor = [UIColor yellowColor];

shadowOffset:阴影大小                            label.shadowOffset = CGSizeMake(2,1);

2.3高亮设置

highlighted :BOOL值,是否高亮

highlightedTextColor:高亮时的颜色

2.4用户交互

userInteractionEnabled                          label.userInteractionEnabled = YES;默认用户交互为关闭