NSMutableParagraphStyle/NSParagraphStyle and nsparagraphstyle

Source: Internet
Author: User

NSMutableParagraphStyle/NSParagraphStyle and nsparagraphstyle

    1. // NSParagraphStyleAttributeName specifies the style of the paragraph (set the first line, line spacing, and alignment). You can see what attributes you need and what you want to write.
    2. NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    3. ParagraphStyle. lineSpacing = 10; // line spacing of the font
    4. ParagraphStyle. firstLineHeadIndent = 20366f; // indent the first line
    5. ParagraphStyle. alignment = NSTextAlignmentJustified; // text alignment: (left, center, right, and both ends)
    6. ParagraphStyle. lineBreakMode = NSLineBreakByTruncatingTail; // the content of the end part is ...... Method omitted ("... wxyz", "abcd...", "AB... yz ")
    7. ParagraphStyle. headIndent = 20; // overall indent (excluding the first line)
    8. ParagraphStyle. tailIndent = 20 ;//
    9. ParagraphStyle. minimumLineHeight = 10; // The lowest row height.
    10. ParagraphStyle. maximumLineHeight = 20; // The highest Row Height
    11. ParagraphStyle. paragraphSpacing = 15; // the spacing between segments.
    12. ParagraphStyle. paragraphSpacingBefore = 22.0f; // blank space in the first line of the field/* Distance between the bottom of the previous paragraph (or the end of its paragraphSpacing, if any) and the top of this paragraph. */
    13. ParagraphStyle. baseWritingDirection = nswritingdirelefttoright; // Write direction from left to right (three types in total)
    14. ParagraphStyle. lineHeightMultiple = 15;/* Natural line height is multiplied by this factor (if positive) before being constrained by minimum and maximum line height .*/
    15. ParagraphStyle. hyphenationFactor = 1; // in iOS, the only supported values are 0 and 1.
    16. /*
    17. NSFontAttributeName font size
    18. NSParagraphStyleAttributeName paragraph style (set the first line, line spacing, alignment or something)
    19. NSKernAttributeName spacing
    20. */
    21. NSDictionary * attributes = @{
    22. NSFontAttributeName: [UIFont systemFontOfSize: 15],
    23. NSParagraphStyleAttributeName: paragraphStyle,
    24. NSKernAttributeName: @ (10 ),
    25. };
    26. TextView. attributedText = [[NSAttributedString alloc] initWithString: textView. text attributes: attributes];

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.