NSParagraphStyle Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in iOS 6.0 and later. |
| Companion guide | Rulers and Paragraph Styles |
| Declared in | NSParagraphStyle.h |
Overview
The NSParagraphStyle class and its subclass NSMutableParagraphStyle encapsulate the paragraph or ruler attributes used by the NSAttributedString classes. Instances of these classes are often referred to as paragraph style objects or, when no confusion will result, paragraph styles.
The mutable subclass of NSParagraphStyle is NSMutableParagraphStyle.
Adopted Protocols
Tasks
Creating an NSParagraphStyle
Accessing Style Information
-
alignmentproperty -
firstLineHeadIndentproperty -
headIndentproperty -
tailIndentproperty -
lineHeightMultipleproperty -
maximumLineHeightproperty -
minimumLineHeightproperty -
lineSpacingproperty -
paragraphSpacingproperty -
paragraphSpacingBeforeproperty
Getting Line Breaking Information
-
lineBreakModeproperty -
hyphenationFactorproperty
Writing Direction
Properties
alignment
The text alignment of the receiver. (read-only)
Discussion
Natural text alignment is realized as left or right alignment depending on the line sweep direction of the first script contained in the paragraph.
Availability
- Available in iOS 6.0 and later.
Declared In
NSParagraphStyle.hbaseWritingDirection
The base writing direction for the receiver. (read-only)
Discussion
If you the value of this property is NSWritingDirectionNaturalDirection, the receiver resolves the writing direction to either NSWritingDirectionLeftToRight or NSWritingDirectionRightToLeft, depending on the direction for the user’s language preference setting.
Availability
- Available in iOS 6.0 and later.
Declared In
NSParagraphStyle.hfirstLineHeadIndent
The indentation of the first line of the receiver. (read-only)
Discussion
This property contains the distance (in points) from the leading margin of a text container to the beginning of the paragraph’s first line. This value is always nonnegative.
Availability
- Available in iOS 6.0 and later.
See Also
Declared In
NSParagraphStyle.hheadIndent
The indentation of the receiver’s lines other than the first. (read-only)
Discussion
This property contains the distance (in points) from the leading margin of a text container to the beginning of lines other than the first. This value is always nonnegative.
Availability
- Available in iOS 6.0 and later.
Declared In
NSParagraphStyle.hhyphenationFactor
The paragraph’s threshold for hyphenation. (read-only)
Discussion
Hyphenation is attempted when the ratio of the text width (as broken without hyphenation) to the width of the line fragment is less than the hyphenation factor. When the paragraph’s hyphenation factor is 0.0, the layout manager’s hyphenation factor is used instead. When both are 0.0, hyphenation is disabled.
Availability
- Available in iOS 6.0 and later.
Declared In
NSParagraphStyle.hlineBreakMode
The mode that should be used to break lines in the receiver. (read-only)
Discussion
This property contains the line break mode to be used laying out the paragraph’s text.
Availability
- Available in iOS 6.0 and later.
Declared In
NSParagraphStyle.hlineHeightMultiple
The line height multiple. (read-only)
Discussion
The natural line height of the receiver is multiplied by this factor (if positive) before being constrained by minimum and maximum line height. The default value of this property is 0.0.
Availability
- Available in iOS 6.0 and later.
Declared In
NSParagraphStyle.hlineSpacing
The space between lines in the receiver (commonly known as leading). (read-only)
Discussion
This property contains the space in points added between lines within the paragraph. This value is always nonnegative
Availability
- Available in iOS 6.0 and later.
Declared In
NSParagraphStyle.hmaximumLineHeight
The receiver’s maximum line height. (read-only)
Discussion
This property contains the maximum height in points that any line in the receiver will occupy, regardless of the font size or size of any attached graphic. This value is always nonnegative. The default value is 0.
Glyphs and graphics exceeding this height will overlap neighboring lines; however, a maximum height of 0 implies no line height limit. Although this limit applies to the line itself, line spacing adds extra space between adjacent lines.
Availability
- Available in iOS 6.0 and later.
Declared In
NSParagraphStyle.hminimumLineHeight
The receiver’s minimum height. (read-only)
Discussion
This property contains the minimum height in points that any line in the receiver will occupy, regardless of the font size or size of any attached graphic. This value is always nonnegative
Availability
- Available in iOS 6.0 and later.
Declared In
NSParagraphStyle.hparagraphSpacing
The space after the end of the paragraph. (read-only)
Discussion
This property contains the space (measured in points) added at the end of the paragraph to separate it from the following paragraph. This value is always nonnegative. The space between paragraphs is determined by adding the previous paragraph’s paragraphSpacing and the current paragraph’s paragraphSpacingBefore.
Availability
- Available in iOS 6.0 and later.
Declared In
NSParagraphStyle.hparagraphSpacingBefore
The distance between the paragraph’s top and the beginning of its text content. (read-only)
Discussion
This property contains the space (measured in points) between the paragraph’s top and the beginning of its text content. The default value of this property is 0.0.
Availability
- Available in iOS 6.0 and later.
See Also
Declared In
NSParagraphStyle.htailIndent
The trailing indentation of the receiver. (read-only)
Discussion
If positive, this value is the distance from the leading margin (for example, the left margin in left-to-right text). If 0 or negative, it’s the distance from the trailing margin.
For example, a paragraph style designed to fit exactly in a 2-inch wide container has a head indent of 0.0 and a tail indent of 0.0. One designed to fit with a quarter-inch margin has a head indent of 0.25 and a tail indent of –0.25.
Availability
- Available in iOS 6.0 and later.
Declared In
NSParagraphStyle.hClass Methods
defaultParagraphStyle
Returns the default paragraph style.
Discussion
The default paragraph style has the following default values:
Subattribute |
Default Value |
|---|---|
Alignment |
|
Tab stops (Mac OS X only) |
12 left-aligned tabs, spaced by 28.0 points |
Line break mode |
|
All others |
0.0 |
See individual method descriptions for explanations of each subattribute.
Availability
- Available in iOS 6.0 and later.
Declared In
NSParagraphStyle.hdefaultWritingDirectionForLanguage:
Returns the default writing direction for the specified language.
Parameters
- languageName
The language specified in ISO language region format. Can be
nilto return a default writing direction derived from the user’s defaults database.
Return Value
The default writing direction.
Availability
- Available in iOS 6.0 and later.
See Also
Declared In
NSParagraphStyle.hConstants
NSLineBreakMode
These constants specify what happens when a line is too long for its container.
enum {
NSLineBreakByWordWrapping = 0,
NSLineBreakByCharWrapping,
NSLineBreakByClipping,
NSLineBreakByTruncatingHead,
NSLineBreakByTruncatingTail,
NSLineBreakByTruncatingMiddle
};
typedef NSUInteger NSLineBreakMode
Constants
NSLineBreakByWordWrappingWrapping occurs at word boundaries, unless the word itself doesn’t fit on a single line.
Available in iOS 6.0 and later.
Declared in
NSParagraphStyle.h.NSLineBreakByCharWrappingWrapping occurs before the first character that doesn’t fit.
Available in iOS 6.0 and later.
Declared in
NSParagraphStyle.h.NSLineBreakByClippingLines are simply not drawn past the edge of the text container.
Available in iOS 6.0 and later.
Declared in
NSParagraphStyle.h.NSLineBreakByTruncatingHeadThe line is displayed so that the end fits in the container and the missing text at the beginning of the line is indicated by an ellipsis glyph. Although this mode works for multiline text, it is more often used for single line text.
Available in iOS 6.0 and later.
Declared in
NSParagraphStyle.h.NSLineBreakByTruncatingTailThe line is displayed so that the beginning fits in the container and the missing text at the end of the line is indicated by an ellipsis glyph. Although this mode works for multiline text, it is more often used for single line text.
Available in iOS 6.0 and later.
Declared in
NSParagraphStyle.h.NSLineBreakByTruncatingMiddleThe line is displayed so that the beginning and end fit in the container and the missing text in the middle is indicated by an ellipsis glyph. Although this mode works for multiline text, it is more often used for single line text.
Available in iOS 6.0 and later.
Declared in
NSParagraphStyle.h.
© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-09-19)