Post on 10-May-2015
UITEXTKIT IOS7
TEXT KIT 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
TEXT KITThe developers can make use of the
following classes:
NSAttributedString NSLayoutManager NSTextContainer NSTextStorage
NSATTRIBUTEDSTRING 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/UIKit.framework
NSATTRIBUTEDSTRING (INSTANCE METHODS) 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:
NSTEXTSTORAGE The NSTextStorage class defines the
fundamental interface for managing text-based content.
Framework/System/Library/Frameworks/UIKit.framework
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
NSTEXTSTORAGE (PROPERTIES)
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
NSTEXTSTORAGE (INSTANCE METHODS) Handling Text Edited Messages– edited:range:changeInLength:– ensureAttributesAreFixedInRange:– invalidateAttributesInRange:– processEditing Handling Layout Managers– addLayoutManager:– removeLayoutManager:
NSTEXTCONTAINER The NSTextContainer class defines a region where
text is laid out Framework/System/Library/Frameworks/
UIKit.framework 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
NSTEXTCONTAINER (PROPERTIES) 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
NSTEXTCONTAINER (INSTANCE METHODS) Creating a Text Container– initWithSize: Laying Out Text– lineFragmentRectForProposedRect:atIndex:writingDirection:remainingRect:
NSLAYOUTMANAGER The NSLayoutManager class generates glyphs and
lays out text Framework/System/Library/Frameworks/
UIKit.framework 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
NSLAYOUTMANAGER (PROPERTIES) Text Storage textStorage property Text Containers textContainers property Delegate delegate property Global Layout Manager Options allowsNonContiguousLayout property hasNonContiguousLayout property hyphenationFactor property showsControlCharacters property showsInvisibleCharacters property usesFontLeading property
NSLAYOUTMANAGER (PROPERTIES) Getting Glyphs and Glyph Properties numberOfGlyphs property Getting Layout Information extraLineFragmentRect property extraLineFragmentTextContainer property
extraLineFragmentUsedRect property
NSLAYOUTMANAGER (INSTANCE METHODS) Text Containers– addTextContainer:– insertTextContainer:atIndex:– removeTextContainerAtIndex:– setTextContainer:forGlyphRange:– textContainerChangedGeometry:textContainerForGlyphAtIndex:effectiveRange:– usedRectForTextContainer: Invalidation of Layout and Glyphs– invalidateDisplayForCharacterRange:– invalidateDisplayForGlyphRange:– invalidateGlyphsForCharacterRange:changeInLength:actualCharacterRange:–
invalidateLayoutForCharacterRange:actualCharacterRange:
– processEditingForTextStorage:edited:range:changeInLength:invalidatedRange:
NSLAYOUTMANAGER (INSTANCE METHODS) Causing Glyph Generation and Layout– ensureGlyphsForCharacterRange:– ensureGlyphsForGlyphRange:
ensureLayoutForBoundingRect:inTextContainer:
– ensureLayoutForCharacterRange:– ensureLayoutForGlyphRange:– ensureLayoutForTextContainer: Setting Glyphs and Glyph PropertiessetGlyphs:properties:characterIndexes:font:forGlyphRange
:
NSLAYOUTMANAGER (INSTANCE METHODS) Getting Glyphs and Glyph Properties– characterIndexForGlyphAtIndex:– getGlyphsInRange:glyphs:properties:characterIndexes:bidiLevels:– glyphAtIndex:– glyphAtIndex:isValidIndex:– glyphIndexForCharacterAtIndex:– isValidGlyphIndex:– propertyForGlyphAtIndex: Setting Layout Information– setAttachmentSize:forGlyphRange:– setDrawsOutsideLineFragment:forGlyphAtIndex:– setExtraLineFragmentRect:usedRect:textContainer:– setLineFragmentRect:forGlyphRange:usedRect:– setLocation:forStartOfGlyphRange:– setNotShownAttribute:forGlyphAtIndex:
NSLAYOUTMANAGER (INSTANCE METHODS) Getting Layout Information– attachmentSizeForGlyphAtIndex:– drawsOutsideLineFragmentForGlyphAtIndex :– firstUnlaidCharacterIndex– firstUnlaidGlyphIndex– getFirstUnlaidCharacterIndex:glyphIndex :– lineFragmentRectForGlyphAtIndex:effectiveRange :– lineFragmentUsedRectForGlyphAtIndex:effectiveRange :– locationForGlyphAtIndex:– notShownAttributeForGlyphAtIndex:– truncatedGlyphRangeInLineFragmentForGlyphAtIndex :
NSLAYOUTMANAGER (INSTANCE METHODS) Advanced Layout Queries– boundingRectForGlyphRange:inTextContainer :– characterIndexForPoint:inTextContainer:fractionOfDistanceBetweenInsertionPoints:– characterRangeForGlyphRange:actualGlyphRange :– enumerateEnclosingRectsForGlyphRange:withinSelectedGlyphRange:inTextContainer:usingBlock:– enumerateLineFragmentsForGlyphRange:usingBlock:– fractionOfDistanceThroughGlyphForPoint:inTextContainer :– getLineFragmentInsertionPointsForCharacterAtIndex:alternatePositions:inDisplayOrder:positions:characterIndexes:– glyphIndexForPoint:inTextContainer:– glyphIndexForPoint:inTextContainer:fractionOfDistanceThroughGlyph:– glyphRangeForBoundingRect:inTextContainer :– glyphRangeForBoundingRectWithoutAdditionalLayout:inTextContainer:– glyphRangeForCharacterRange:actualCharacterRange :– glyphRangeForTextContainer:– rangeOfNominallySpacedGlyphsContainingIndex:
NSLAYOUTMANAGER (INSTANCE METHODS) Supporting Drawing– drawBackgroundForGlyphRange:atPoint:– drawGlyphsForGlyphRange:atPoint:– drawStrikethroughForGlyphRange:strikethroughType:baselineOffset:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:– drawUnderlineForGlyphRange:underlineType:baselineOffset:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:–
fillBackgroundRectArray:count:forCharacterRange:color:
– showCGGlyphs:positions:count:font:matrix:attributes:inContext:
– strikethroughGlyphRange:strikethroughType:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:– underlineGlyphRange:underlineType:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:
CONCLUSION 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
ANY QUESTIONS???