IOS 7 Applying Kerning and Line Spacing to Text

I have the following code that works flawlessly in iOS 6, the problem is that it has no effect in iOS 7. How to apply kerning and line spacing in iOS 7?

+ (NSAttributedString *)attributedText:(NSString *)text inFont:(UIFont *)font { NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:text]; NSMutableParagraphStyle *style = [NSMutableParagraphStyle new]; style.lineSpacing = 5; CGFloat kernSize = -0.6; [attributedString addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, text.length)]; [attributedString addAttribute:NSKernAttributeName value:@(kernSize) range:NSMakeRange(0, text.length)]; return attributedString; } 
+4
source share
1 answer

Perhaps a duplicate for Why Kerning does not work for NSAttributedString in iOS7

For some strange reason, it does not work with the Courier font (in iOS7!), But with CourierNewPSMT.

Maybe try with different fonts .... here is a good list of fonts on iphone: http://iosfonts.com/

0
source

All Articles