在iOS 7之后,styleString方法不再起作用。有两种新的选择。首先是TextKit;强大的新版式引擎。要更改行距,请设置UITextView的布局管理器的委托:textView.layoutManager.delegate = self; // you'll need to declare you implement the NSLayoutManagerDelegate protocol然后重写此委托方法:- (CGFloat)layoutManager:(NSLayoutManager *)layoutManager lineSpacingAfterGlyphAtIndex:(NSUInteger)glyphIndex withProposedLineFragmentRect:(CGRect)rect{ return 20; // For really wide spacing; pick your own value}其次,iOS 7现在支持NSParagraphStyle的lineSpacing。这样可以提供更多控制,例如第一行缩进和边界矩形的计算。所以或者...NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];paragraphStyle.headIndent = 15; // <--- indention if you need itparagraphStyle.firstLineHeadIndent = 15;paragraphStyle.lineSpacing = 7; // <--- magic line spacing here!NSDictionary *attrsDictionary =@{ NSParagraphStyleAttributeName: paragraphStyle }; // <-- there are many more attrs, e.g NSFontAttributeNameself.textView.attributedText = [[NSAttributedString alloc] initWithString:@"Hello World over many lines!" attributes:attrsDictionary];FWIW,在iOS7下也没有使用旧的contentInset方法来沿UITextView的左边缘对齐文本。相反,要删除边距:textView.textContainer.lineFragmentPadding = 0;