DTCoreTextParagraphStyle Class Reference
Inherits from | NSObject |
Conforms to | NSCopying |
Declared in | DTCoreTextParagraphStyle.h |
Overview
DTCoreTextParagraphStyle
encapsulates the paragraph or ruler attributes used by the NSAttributedString classes on iOS. It is a replacement for NSParagraphStyle
which is not implemented on iOS.
Since NSAttributedString
instances use CTParagraphStyle object there are methods to bridge from and to these. Because of this distinction there is no need for a mutable variant of this class.
Tasks
Creating a DTCoreTextParagraphStyle
Bridging to and from CTParagraphStyle
-
+ paragraphStyleWithCTParagraphStyle:
-
– initWithCTParagraphStyle:
-
– createCTParagraphStyle
-
+ paragraphStyleWithNSParagraphStyle:
-
– NSParagraphStyle
Accessing Style Information
-
firstLineHeadIndent
property -
defaultTabInterval
property -
paragraphSpacingBefore
property -
paragraphSpacing
property -
lineHeightMultiple
property -
minimumLineHeight
property -
maximumLineHeight
property -
tailIndent
property -
headIndent
property -
alignment
property -
baseWritingDirection
property
Setting Tab Stops
Interacting with CSS
Setting Text Lists
-
textLists
property
Setting Text Blocks
-
textBlocks
property
Properties
alignment
The text alignment of the receiver.
@property (nonatomic, assign) CTTextAlignment alignment
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.
Declared In
DTCoreTextParagraphStyle.h
baseWritingDirection
The base writing direction for the receiver.
@property (nonatomic, assign) CTWritingDirection baseWritingDirection
Declared In
DTCoreTextParagraphStyle.h
defaultTabInterval
The document-wide default tab interval.
@property (nonatomic, assign) CGFloat defaultTabInterval
Discussion
The default tab interval in points. Tabs after the last specified in tabStops are placed at integer multiples of this distance (if positive). Default return value is 0.0.
Declared In
DTCoreTextParagraphStyle.h
firstLineHeadIndent
The indentation of the first line of the receiver.
@property (nonatomic, assign) CGFloat firstLineHeadIndent
Declared In
DTCoreTextParagraphStyle.h
headIndent
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.
@property (nonatomic, assign) CGFloat headIndent
Declared In
DTCoreTextParagraphStyle.h
lineHeightMultiple
The line height multiple.
@property (nonatomic, assign) CGFloat lineHeightMultiple
Discussion
Internally line height multiples get converted into minimum and maximum line height.
Declared In
DTCoreTextParagraphStyle.h
maximumLineHeight
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.
@property (nonatomic, assign) CGFloat maximumLineHeight
Declared In
DTCoreTextParagraphStyle.h
minimumLineHeight
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.
@property (nonatomic, assign) CGFloat minimumLineHeight
Declared In
DTCoreTextParagraphStyle.h
paragraphSpacing
The space after the end of the paragraph.
@property (nonatomic, assign) CGFloat paragraphSpacing
Declared In
DTCoreTextParagraphStyle.h
paragraphSpacingBefore
The distance between the paragraph’s top and the beginning of its text content.
@property (nonatomic, assign) CGFloat paragraphSpacingBefore
Declared In
DTCoreTextParagraphStyle.h
tabStops
The CTTextTab objects, sorted by location, that define the tab stops for the paragraph style.
@property (nonatomic, copy) NSArray *tabStops
Declared In
DTCoreTextParagraphStyle.h
tailIndent
The distance in points from the margin of a text container to the end of lines.
@property (nonatomic, assign) CGFloat tailIndent
Discussion
Note: This value is negative if it is to be measured from the trailing margin, positive if measured from the same margin as the headIndent.
Declared In
DTCoreTextParagraphStyle.h
textBlocks
Text blocks containing the paragraph, nested from outermost to innermost, to array. Each text block is a DTTextBlock object.
@property (nonatomic, copy) NSArray *textBlocks
Declared In
DTCoreTextParagraphStyle.h
textLists
Text lists containing the paragraph, nested from outermost to innermost. Each text list is a DTCSSListStyle object.
@property (nonatomic, copy) NSArray *textLists
Declared In
DTCoreTextParagraphStyle.h
Class Methods
defaultParagraphStyle
Returns the default paragraph style.
+ (DTCoreTextParagraphStyle *)defaultParagraphStyle
Declared In
DTCoreTextParagraphStyle.h
paragraphStyleWithCTParagraphStyle:
Create a new paragraph style instance from a CTParagraphStyle
.
+ (DTCoreTextParagraphStyle *)paragraphStyleWithCTParagraphStyle:(CTParagraphStyleRef)ctParagraphStyle
Parameters
- ctParagraphStyle
the
CTParagraphStyle
from which to copy this new style’s attributes.
Declared In
DTCoreTextParagraphStyle.h
paragraphStyleWithNSParagraphStyle:
Create a new paragraph style instance from an NSParagraphStyle
.
+ (DTCoreTextParagraphStyle *)paragraphStyleWithNSParagraphStyle:(NSParagraphStyle *)paragraphStyle
Parameters
- paragraphStyle
the
NSParagraphStyle
from which to copy this new style’s attributes.
Discussion
Note: on iOS no tab stops are supported.
Declared In
DTCoreTextParagraphStyle.h
Instance Methods
NSParagraphStyle
Create a new NSParagraphStyle
from the receiver for use as attribute in NSAttributedString
.
- (NSParagraphStyle *)NSParagraphStyle
Return Value
The NSParagraphStyle
based on the receiver’s attributes.
Discussion
Note: This method is requires iOS 6 or greater. This does not support tab stops.
Declared In
DTCoreTextParagraphStyle.h
addTabStopAtPosition:alignment:
Adds a tab stop to the receiver.
- (void)addTabStopAtPosition:(CGFloat)position alignment:(CTTextAlignment)alignment
Declared In
DTCoreTextParagraphStyle.h
createCTParagraphStyle
Create a new CTParagraphStyle
from the receiver for use as attribute in NSAttributedString
- (CTParagraphStyleRef)createCTParagraphStyle
Return Value
The CTParagraphStyle
based on the receiver’s attributes.
Declared In
DTCoreTextParagraphStyle.h