@property (nonatomic, strong) UILabel *Lab;
- (UILabel *)Lab {
if (!_Lab) {
UILabel *label = [[UILabel alloc] init];
label.textAlignment = NSTextAlignmentRight;
label.font = systemFont(16);
label.text = @"label";
label.backgroundColor = [UIColor whiteColor];
label.numberOfLines = 2;
_Lab = label;
}
return _Lab;
}
[self.Lab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.view);
make.height.equalTo(@30);
make.width.equalTo(@30);
}];
其他属性
##字体的设置
self.label.font = [UIFont fontWithName:@"Zapfino" size:20];
###UILable“中文”加上“英文或者其他非中文字符”自动换行的问题,结尾自动换行问题
self.labTitle.lineBreakMode = NSLineBreakByCharWrapping;
self.adviceLabel.lineBreakMode = NSLineBreakByTruncatingTail; //结尾...
###文字大小自适应标签宽度
self.labTitle.adjustsFontSizeToFitWidth = YES;//当文字超出标签宽度时,自动调整文字大小,使其不被截断
解决使用NSMutableAttributedString 设置不同字体,文字不能居中对齐
https://blog.csdn.net/null_nil/article/details/52233096
https://blog.csdn.net/kuangdacaikuang/article/details/79584587
sizeToFit 与 sizeThatFit
https://blog.csdn.net/huangfei711/article/details/77435614
自定义UILabel
http://www.jianshu.com/p/554f88e4b731
计时UILabel
https://github.com/mineschan/MZTimerLabel
TTTAttributedLabel 富文本label
https://www.jianshu.com/p/42d1b4eee88e
https://www.jianshu.com/p/a93b729b5fcb
获取系统字体名称:
NSArray *familyNames = [UIFont familyNames];
for( NSString *familyName in familyNames )
{
NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName];
for( NSString *fontName in fontNames )
{
printf( "\tFont: %s \n", [fontName UTF8String] );
}
}