2. Text Kit is a high-level, feature-rich set of
classes that has all the characteristics for
fine typography to handle text
The developers can add different styles and
formatting to the text, such as columns,
multiple fonts, paragraphs, and pages
It’s responsible for creating, editing,
displaying, and storing text with less code, as
it’s integrated with all UIKit text-based
controls
3. The developers can make use of the following
classes:
NSAttributedString
NSLayoutManager
NSTextContainer
NSTextStorage
4. The UIKit framework adds methods
to NSAttributedString to support the drawing
of styled strings and to compute the size and
metrics of a string prior to drawing
The NSAttributedString class has been
extended to support new attributes
Framework/System/Library/Frameworks/UI
Kit.framework
5. Creating an Attributed String
– initWithData:options:documentAttributes:error:
– initWithFileURL:options:documentAttributes:error:
Drawing the String
– drawAtPoint:
– drawInRect:
– drawWithRect:options:context:
Getting Metrics for the String
– size
– boundingRectWithSize:options:context:
Generating Data
– dataFromRange:documentAttributes:error:
– fileWrapperFromRange:documentAttributes:error:
6. The NSTextStorage class defines the fundamental
interface for managing text-based content.
Framework/System/Library/Frameworks/UIKit.f
ramework
NSTextStorage is a semiconcrete subclass
of NSMutableAttributedString that manages a set
of client NSLayoutManager objects, notifying
them of any changes to its characters or
attributes so that they can relay and redisplay
the text as needed
NSTextStorage defines the fundamental storage
mechanism of the Text Kit’s extended text-
handling system
7. Setting the Delegate
delegate property
Determining the Nature of Changes
editedMask property
changeInLength property
editedRange property
Handling Text Edited Messages
fixesAttributesLazily property
Handling Layout Managers
layoutManagers property
9. The NSTextContainer class defines a region where
text is laid out
Framework/System/Library/Frameworks/UIKit.frame
work
The NSTextContainer class defines a region in which
text is laid out
An NSLayoutManager object uses one or
more NSTextContainer objects to determine where to
break lines, lay out portions of text, and so on
An NSTextContainer object defines rectangular
regions, and you can define exclusion paths inside the
text container's bounding rectangle so that text flows
around the exclusion path as it is laid out
You can create subclasses that define regions of
nonrectangular shapes, such as circular regions
10. Laying Out Text
layoutManager property
Defining the Container Shape
exclusionPaths property
size property
lineBreakMode property
Synchronizing with the Text View
heightTracksTextView property
widthTracksTextView property
Constraining Layout
maximumNumberOfLines property
lineFragmentPadding property
11. Creating a Text Container
– initWithSize:
Laying Out Text
–
lineFragmentRectForProposedRect:atIndex:w
ritingDirection:remainingRect:
12. The NSLayoutManager class generates glyphs and lays
out text
Framework/System/Library/Frameworks/UIKit.frame
work
An NSLayoutManager object coordinates the layout
and display of characters held in
an NSTextStorage object
Maps Unicode character codes to glyphs, sets the
glyphs in a series of NSTextContainer objects, and
displays them in a series of text view objects
coordinates its text view objects, provides services to
those text views to support editing paragraph styles,
and handles the layout and display of text attributes
not inherent in glyphs (such as underline or
strikethrough
21. Lesser Build Size due to lesser use of graphics
to display textual images
Lesser Coding i.e concatenation of two
labels/strings with different layouts is not a
headache now with the release of iOS 7