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

UILabel标签

2015-09-19 19:19 381 查看
创建label:

UILabel *label = [UILabel alloc] initWithFrame:CGRectMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height);


透明度:

label.alpha = 1;


文字及颜色:

label.text = @"标签内容";

label.textColor = @"字体颜色";

label.backgroundColor = [UIColor grayColor];


设置文字居中中/左对齐/右对齐

Center / Left / Right
label.textAlignment = [NSTextAlignmentCenter];


设置弧度,边框,颜色::

label.layer.cornerRadius = 10;
label.layer.borderColor = [UIColor grayColor].CGColor;
label.layer.borderWidth = 1;


RBG三原色:

label.layer.borderColor = [UIColor colorWithRed:(CGFloat) green:(CGFloat) blue:(CGFloat) alpha:(CGFloat)];


编辑框外内容:

label .layer.masksToBounds = YES;


根据文本自适应行数:

label.numberOfLines = NSIntegerMax;  //先设置行数为最大值
[label sizeToFit];


文本阴影颜色:

label.shadowColor = [UIColor grayColor];


阴影效果:

(向右偏移,向下偏移)
label.shadowOffset = CGSizeMake(CGFloat width, CGFloat height);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息