ios - iOS:UILabel多行-标签的第二行需要以10像素开头

标签 ios

enter image description here

我面临的一个问题是-我有一个标签,例如“1. Seibl是某家公司生产的软件,可以$ 500的价格购买”

对于iPhone 4s,标签正在打印第二行,第二行正好在“1”下开始。我想给空格/边距/空格,以便标签看起来像编号格式。

最佳答案

试试这个解决方案。它可能会帮助您。

使用NSAttributedString作为标签,并设置其 headIndent paragraph style:

NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
style.headIndent = 14;
NSDictionary *attributes = @{
    NSParagraphStyleAttributeName: style
};
NSAttributedString *richText = [[NSAttributedString alloc] initWithString:@"So this UILabel walks into a bar…" attributes:attributes];
self.narrowLabel.attributedText = richText;
self.wideLabel.attributedText = richText;

结果:

关于ios - iOS:UILabel多行-标签的第二行需要以10像素开头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35837715/

相关文章:

iOS 9 |联系人框架

javascript - 在页面加载时隐藏基于字符值的选择选项

ios - 查找 Xcode 项目的 ${PROJECT_DIR}

ios - 如何将 UIButtons 添加到我的 TableViewCell 中?

ios - NSSet 的 Coredata 获取谓词

ios - iOS 8.1 iPad Air 2-图像加载内存错误

ios - ADAL 库 - 客户端已请求访问未在客户端应用程序注册中请求的权限中列出的资源

android - 在没有客户端 SDK 的情况下使用 GCM/Firebase

ios - 在 UIAutomation 中获取设备方向

iphone - 如何让 AuGraph 从文件开头重新启动音频文件?