gpt4 book ai didi

iOS 5/6 与 iOS 7 多行标签行间距

转载 作者:技术小花猫 更新时间:2023-10-29 10:59:57 26 4
gpt4 key购买 nike

我在 iOS 7 下运行我的应用程序,发现多行标签(无属性、纯文本)以较小的行距呈现。有人知道如何处理 iOS 5 兼容性吗?

iOS 5/6

iOS 5/6

iOS 7

iOS 7

最佳答案

if(NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1)
{
NSFont *font = /* set font */;

NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[paragraphStyle setLineSpacing: /* required line spacing */];

NSDictionary *attributes = @{ NSFontAttributeName: font, NSParagraphStyleAttributeName: paragraphStyle };
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:@"strigil" attributes:attributes];

[label setAttributedText: attributedString];
}
else
{
/* old method */
}

关于iOS 5/6 与 iOS 7 多行标签行间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18965512/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com