NSTextAlignmentJustified在iOS7中不起作用 [英] NSTextAlignmentJustified not working in iOS7
问题描述
我有一个使用 NSTextAlignmentJustified
的应用程序,用于 NSAttributedString
。在 iOS 6 中,一切都运行良好。但是在 iOS 7 (模拟器或设备没有任何区别)中运行的相同应用程序根本没有显示任何Justify。此外,从 iOS 6 到 7 ,线条间距似乎也发生了巨大变化。
I have an app which uses NSTextAlignmentJustified
for an NSAttributedString
. In iOS 6 everything is working great. But the same App running in iOS 7 (simulator or device makes no difference) is showing no Justify at all. Also the linespacing seems to have changed dramatically from iOS 6 to 7.
其他人遇到此问题?有没有办法在iOS 7中制作合理的Textblock(在iOS 6中也可以使用?)
Anyone else encountered this problem? Is there any way to make a justified Textblock in iOS 7 (which works in iOS 6 too?)
问候,
Markus
Regards, Markus
推荐答案
好的,我找到了一种在iOS 7中制作标签Justifiy的方法:
i只需将NSBaselineOffsetAttributeName设置为0。
Ok, i kind of found a way to make the label Justifiy in iOS 7: i simply set NSBaselineOffsetAttributeName to 0.
不知道为什么会有效,但它确实有效。
No idea why it works, but it works.
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
paragraphStyle.alignment = NSTextAlignmentJustified;
NSAttributedString *string = [[NSAttributedString alloc] initWithString:rawString
attributes:[NSDictionary dictionaryWithObjectsAndKeys:
paragraphStyle, NSParagraphStyleAttributeName ,
[NSNumber numberWithFloat:0],NSBaselineOffsetAttributeName,
nil]];
这篇关于NSTextAlignmentJustified在iOS7中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!