我面临的一个问题是-我有一个标签,例如“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/