您的位置:首页 > 产品设计 > UI/UE

iOS UI Label控件

2015-06-24 09:24 531 查看
text: label 显示的文字;

font : text字体,值不可以是nil。

textColor : text 颜色;

textAlignment: text的对齐方式(左对齐,居中对齐,右对齐) (0左 1中 2右)。

enable: text是否可变   BOOL值(YES,NO);

shadowColor : text的 阴影,包含阴影颜色;

UILabel * redView1 = [[UILabel alloc] initWithFrame:CGRectMake(50, 175, 90, 25)];
UILabel * redView2 = [[UILabel alloc] initWithFrame:CGRectMake(0, 50, 90, 50)];
UIView * blueView1 = [[UIView alloc] initWithFrame:CGRectMake(175, 175, 150, 25)];
UIView * blueView2 = [[UIView alloc] initWithFrame:CGRectMake(0, 50, 150, 25)];
UIView * greenView1 = [[UIView alloc] initWithFrame:CGRectMake(50, 275, 70, 25)];
UIView * greenView2 = [[UIView alloc] initWithFrame:CGRectMake(103, 0, 70, 25)];
UIView * greenView3 = [[UIView alloc] initWithFrame:CGRectMake(103, 0, 70, 25)];

[redView1 setText:@"用户名:"];// 添加文字
redView1.textAlignment = NSTextAlignmentCenter; //居中对齐
redView1.textColor = [UIColor whiteColor]; //设置文字颜色;
//redView1.font = [UIFont fontWithName:@"行楷-Bold" size:16]; 设置文字字体和大小
redView1.font = [UIFont boldSystemFontOfSize:16]; //加粗 字号
[redView2 setText:@"这是我的第二次iOS UI课程,学的是label控件,用法与View基本相同" ];
[redView1 setShadowColor:[UIColor blackColor]];//set 文字阴影 阴影颜色
redView1.shadowOffset = CGSizeMake(2, 0);// 阴影向X轴正方向偏移2,向y偏移0
redView2.textColor = [UIColor whiteColor];
redView2.font = [UIFont systemFontOfSize:16];
redView2.numberOfLines = 2; //显示2行,如果高度不能容纳2行,没显示的以...代替
redView2.textAlignment = NSTextAlignmentCenter;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios ui uilabel