NSMutableParagraphStyle/NSParagraphStyle and nsparagraphstyle
- // 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.
- NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
- ParagraphStyle. lineSpacing = 10; // line spacing of the font
- ParagraphStyle. firstLineHeadIndent = 20366f; // indent the first line
- ParagraphStyle. alignment = NSTextAlignmentJustified; // text alignment: (left, center, right, and both ends)
- ParagraphStyle. lineBreakMode = NSLineBreakByTruncatingTail; // the content of the end part is ...... Method omitted ("... wxyz", "abcd...", "AB... yz ")
- ParagraphStyle. headIndent = 20; // overall indent (excluding the first line)
- ParagraphStyle. tailIndent = 20 ;//
- ParagraphStyle. minimumLineHeight = 10; // The lowest row height.
- ParagraphStyle. maximumLineHeight = 20; // The highest Row Height
- ParagraphStyle. paragraphSpacing = 15; // the spacing between segments.
- 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. */
- ParagraphStyle. baseWritingDirection = nswritingdirelefttoright; // Write direction from left to right (three types in total)
- ParagraphStyle. lineHeightMultiple = 15;/* Natural line height is multiplied by this factor (if positive) before being constrained by minimum and maximum line height .*/
- ParagraphStyle. hyphenationFactor = 1; // in iOS, the only supported values are 0 and 1.
- /*
- NSFontAttributeName font size
- NSParagraphStyleAttributeName paragraph style (set the first line, line spacing, alignment or something)
- NSKernAttributeName spacing
- */
- NSDictionary * attributes = @{
- NSFontAttributeName: [UIFont systemFontOfSize: 15],
- NSParagraphStyleAttributeName: paragraphStyle,
- NSKernAttributeName: @ (10 ),
- };
- TextView. attributedText = [[NSAttributedString alloc] initWithString: textView. text attributes: attributes];