objective-c - Objective C 标签行间距?

标签 objective-c uilabel lines spacing

有没有办法在 UILabel 中设置两条线的距离? 我试图在 Interface Builder 中完成它但没有成功。

最佳答案

你想要的代码应该是这样的:

NSMutableAttributedString* attrString = [[NSMutableAttributedString  alloc] initWithString:@"Sample text"];
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
[style setLineSpacing:24];
[attrString addAttribute:NSParagraphStyleAttributeName
    value:style
    range:NSMakeRange(0, strLength)];
uiLabel.attributedText = attrString;

关于objective-c - Objective C 标签行间距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43498344/

相关文章:

objective-c - 调用 AVMutableCompositionTrack insertTimeRange 时 AVErrorMediaServicesWereReset

ios - DetailViewController 中的保留周期 - 启用 ARC

ios - 像表格一样显示具有动态大小的标签,但不重叠

ios - 如何根据 UITableView 中的文本增加 UILabel 高度?

ios - 多行自动收缩标签 Swift

python - 在Python中连接两个不同数组的点

iOS:包含日期的存档路径

objective-c - 为什么将 useSingleLineMode 设置为 YES 的 NSTextField 具有多行文本的固有内容大小?

linux - 将一些行组合成一个

delphi - 如何编辑备忘录中的文本?