iOS-UILabel的使用

 常用属性UILabel
//显示的文字
@property(nonatomic,copy)   NSString           *text;
//字体
@property(nonatomic,retain) UIFont             *font;
//文字颜色
@property(nonatomic,retain) UIColor            *textColor;
//对齐模式(比如左对齐、居中对齐、右对齐)
@property(nonatomic)        NSTextAlignment    textAlignment;

[label setTextAlignment:NSTextAlignmentCenter]; //文字显示的位置

self.titleLabel.font = [UIFont systemFontOfSize:12]; //文字的大小
/根据字体大小、宽度、换行模式获得字体的高度

NSString *str = self.textLabel.text;

CGSize textSize = [str sizeWithFont:UIFont systemFontOfSize:14.0] constrainedToSize:CGSizeMake(w, 10000)

lineBreakMode:NOLine];

CGFloat h = textSize.height;
[_textLabel setNumberOfLines:0]; //自动换行
原文地址:https://www.cnblogs.com/linxiu-0925/p/5058121.html