创建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);