iOS 设置TextView控件内容行间距

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
    if (textView.text.length < 1)
    {
        textView.text = TextViewDefault;
    }
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    
    paragraphStyle.lineSpacing = 5;// 字体的行间距
    
    NSDictionary *attributes = @{
                                 
                                 NSParagraphStyleAttributeName:paragraphStyle
                                 
                                 };
    
    textView.attributedText = [[NSAttributedString alloc] initWithString:textView.text attributes:attributes];
    if ([textView.text isEqualToString:TextViewDefault])
    {
        textView.attributedText = [[NSAttributedString alloc] initWithString:@"" attributes:attributes];
    }
    return YES;
}
原文地址:https://www.cnblogs.com/fuunnyy/p/5208621.html