I have been trying to use the attributedText property of UITextView to add adjustable line height to my custom UITextView. My code works fine in the simulator, but I am unable to make it work on an iPhone5. If I remove the font line the line height works but it the text reverts to a default smaller font. If I add the font, the font works but the paragraph styling is ignored. I have tried the code on a vanilla UITextView in a fresh app with the same behavior, which makes me think this is an iOS6 bug. Has anyone had any better luck?
I have also tried various UITextView replacements to add line height functionality, but nothing has worked out so far.
My code looks like this:
...
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.minimumLineHeight = lineHeight;
paragraphStyle.maximumLineHeight = lineHeight;
NSString *text = self.text;
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:text];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, text.length)];
[attributedString addAttribute:NSFontAttributeName value:self.font range:NSMakeRange(0, text.length)];
self.attributedText = attributedString;
Thanks for any confirmation or suggestions anyone has!