简体   繁体   中英

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.

在此处输入图片说明

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...

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM