目标C标签行间距? [英] Objective C label line spacing?

查看:109
本文介绍了目标C标签行间距?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在UILabel中设置两条线的距离? 我尝试在Interface Builder中执行此操作,但未成功.

Is there a way to set the distance of two lines within a UILabel? I tried to do it within Interface Builder but without success.

推荐答案

所需的代码将如下所示:

The code you want will be something like this:

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;

这篇关于目标C标签行间距?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆