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;
}

 

posted @ 2016-02-23 00:44  懒懒初阳  阅读(1129)  评论(0编辑  收藏  举报