Sam
Sam

Reputation: 431

Multiple paragraphSpacing in NSMutableParagraphStyle

In NSMutableParagraphStyle the paragraphSpacing Works perfectly fine.

but i am using bullet points also.

When user Press Return(Enter) then new Paragraph will come.

so when User type bullet points in Uitextview then in between two Points the paragaph spacing should be small and in rest of all the paragraph spacing is something high.

My code is...

    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    paragraphStyle.minimumLineHeight = 0.f;
    paragraphStyle.maximumLineHeight = 16.f;
    paragraphStyle.firstLineHeadIndent = 16.0;
    paragraphStyle.paragraphSpacing = 7.0;
    paragraphStyle.lineSpacing = 5.0;
    paragraphStyle.headIndent = 16.0;
    paragraphStyle.lineBreakMode=NSLineBreakByWordWrapping;
    paragraphStyle.tailIndent=305.0;
    mutattstr1 = [[NSMutableAttributedString alloc] initWithAttributedString:txtViewOfNotes.attributedText];
    [mutattstr1  addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, mutattstr1.length)];
    [txtViewOfNotes setAttributedText:mutattstr1]; 

Like in this text view i need to give small space in between two bullet points line.

enter image description here

So, how to get multiple line spacing or paragraph spacing or any other thing related to this in app.

Any kind of link, idea, code, dock is welcomed...

Upvotes: 0

Views: 2073

Answers (1)

roycable
roycable

Reputation: 301

You can have multiple NSMutableParagraphStyle in the one NSAttributedStrings by using the range attributes - just like you've already done.

You'll just have to detect where you want each NSMutableParagraphStyle and apply with various NSRange. That's the "fun" part.

Upvotes: 1

Related Questions