text kit ios7

22
UITEXTKIT IOS7

Upload: alizaqasim

Post on 10-May-2015

1.429 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Text kit ios7

UITEXTKIT IOS7

Page 2: Text kit 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

Page 3: Text kit ios7

TEXT KITThe developers can make use of the

following classes:

NSAttributedString NSLayoutManager NSTextContainer NSTextStorage

Page 4: Text kit ios7

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

Page 5: Text kit ios7

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:

Page 6: Text kit ios7

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

Page 8: Text kit ios7

NSTEXTSTORAGE (INSTANCE METHODS) Handling Text Edited Messages– edited:range:changeInLength:– ensureAttributesAreFixedInRange:– invalidateAttributesInRange:– processEditing Handling Layout Managers– addLayoutManager:– removeLayoutManager:

Page 9: Text kit ios7

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

Page 10: Text kit ios7

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

Page 12: Text kit ios7

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

Page 13: Text kit ios7

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

Page 15: Text kit ios7

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:

Page 16: Text kit ios7

NSLAYOUTMANAGER (INSTANCE METHODS) Causing Glyph Generation and Layout– ensureGlyphsForCharacterRange:– ensureGlyphsForGlyphRange: 

ensureLayoutForBoundingRect:inTextContainer:

– ensureLayoutForCharacterRange:– ensureLayoutForGlyphRange:– ensureLayoutForTextContainer: Setting Glyphs and Glyph PropertiessetGlyphs:properties:characterIndexes:font:forGlyphRange

:

Page 17: Text kit ios7

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:

Page 18: Text kit ios7

NSLAYOUTMANAGER (INSTANCE METHODS) Getting Layout Information– attachmentSizeForGlyphAtIndex:– drawsOutsideLineFragmentForGlyphAtIndex :– firstUnlaidCharacterIndex– firstUnlaidGlyphIndex– getFirstUnlaidCharacterIndex:glyphIndex :– lineFragmentRectForGlyphAtIndex:effectiveRange :– lineFragmentUsedRectForGlyphAtIndex:effectiveRange :– locationForGlyphAtIndex:– notShownAttributeForGlyphAtIndex:– truncatedGlyphRangeInLineFragmentForGlyphAtIndex :

Page 19: Text kit ios7

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:

Page 20: Text kit ios7

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:

Page 21: Text kit ios7

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

Page 22: Text kit ios7

ANY QUESTIONS???