After iOS 7, the styleString style no longer works.
Two new alternatives are available.
Firstly, TextKit; powerful new layout engine. To change line spacing, set the UITextView layout manager delegate:
textView.layoutManager.delegate = self;
Then override this delegate method:
- (CGFloat)layoutManager:(NSLayoutManager *)layoutManager lineSpacingAfterGlyphAtIndex:(NSUInteger)glyphIndex withProposedLineFragmentRect:(CGRect)rect { return 20;
Secondly, iOS 7 now supports NSParagraphStyle lineSpacing. This gives even more control, for example. indent the first line and calculate the bounding box. So alternatively ...
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; paragraphStyle.headIndent = 15;
FWIW, the old contentInset method for aligning text along the left edge of a UITextView is also not used in iOS7. Instead, to remove the field:
textView.textContainer.lineFragmentPadding = 0;
Graham Perks Sep 18 '13 at 15:33 2013-09-18 15:33
source share