DTAttributedTextContentViewDelegate Protocol Reference
Conforms to | NSObject |
Declared in | DTAttributedTextContentView.h |
Overview
Protocol to provide custom views for elements in an DTAttributedTextContentView. Also the delegate gets notified once the text view has been drawn.
Tasks
Notifications
-
– attributedTextContentView:willDrawLayoutFrame:inContext:
-
– attributedTextContentView:didDrawLayoutFrame:inContext:
-
– attributedTextContentView:shouldDrawBackgroundForTextBlock:frame:context:forLayoutFrame:
Providing Custom Views for Content
Instance Methods
attributedTextContentView:didDrawLayoutFrame:inContext:
Called after a layout frame or a part of it is drawn. The text delegate can draw contents that goes over the text in this method.
- (void)attributedTextContentView:(DTAttributedTextContentView *)attributedTextContentView didDrawLayoutFrame:(DTCoreTextLayoutFrame *)layoutFrame inContext:(CGContextRef)context
Parameters
- attributedTextContentView
The content view that drew a layout frame
- layoutFrame
The layout frame that was drawn for
- context
The graphics context that was drawn into
Declared In
DTAttributedTextContentView.h
attributedTextContentView:shouldDrawBackgroundForTextBlock:frame:context:forLayoutFrame:
Called before the text belonging to a text block is drawn.
- (BOOL)attributedTextContentView:(DTAttributedTextContentView *)attributedTextContentView shouldDrawBackgroundForTextBlock:(DTTextBlock *)textBlock frame:(CGRect)frame context:(CGContextRef)context forLayoutFrame:(DTCoreTextLayoutFrame *)layoutFrame
Parameters
- attributedTextContentView
The content view that drew a layout frame
- textBlock
The text block
- frame
The frame within the content view’s coordinate system that will be drawn into
- context
The graphics context that will be drawn into
- layoutFrame
The layout frame that will be drawn for
Return Value
YES
is the standard fill of the text block should be drawn, NO
if it should not
Discussion
This gives the developer an opportunity to draw a custom background below a text block.
Declared In
DTAttributedTextContentView.h
attributedTextContentView:viewForAttachment:frame:
Provide custom view for an attachment, e.g. an imageView for images
- (UIView *)attributedTextContentView:(DTAttributedTextContentView *)attributedTextContentView viewForAttachment:(DTTextAttachment *)attachment frame:(CGRect)frame
Parameters
- attributedTextContentView
The content view asking for a custom view
- attachment
The DTTextAttachment that this view should represent
- frame
The frame that the view should use to fit on top of the space reserved for the attachment
Return Value
The view that should represent the given attachment
Declared In
DTAttributedTextContentView.h
attributedTextContentView:viewForAttributedString:frame:
Provide generic views for all attachments.
- (UIView *)attributedTextContentView:(DTAttributedTextContentView *)attributedTextContentView viewForAttributedString:(NSAttributedString *)string frame:(CGRect)frame
Parameters
- attributedTextContentView
The content view asking for a custom view
- string
The attributed sub-string containing this element
- frame
The frame that the view should use to fit on top of the space reserved for the attachment
Return Value
The view that should represent the given hyperlink or text attachment
Discussion
This is only called if the more specific delegate methods are not implemented.
See Also
Declared In
DTAttributedTextContentView.h
attributedTextContentView:viewForLink:identifier:frame:
Provide button to be placed over links, the identifier is used to link multiple parts of the same A tag
- (UIView *)attributedTextContentView:(DTAttributedTextContentView *)attributedTextContentView viewForLink:(NSURL *)url identifier:(NSString *)identifier frame:(CGRect)frame
Parameters
- attributedTextContentView
The content view asking for a custom view
- url
The
NSURL
of the hyperlink
- identifier
An identifier that uniquely identifies the hyperlink within the document
- frame
The frame that the view should use to fit on top of the space reserved for the attachment
Return Value
The view that should represent the given hyperlink
Declared In
DTAttributedTextContentView.h
attributedTextContentView:willDrawLayoutFrame:inContext:
Called before a layout frame or a part of it is drawn. The text delegate can draw contents that goes under the text in this method.
- (void)attributedTextContentView:(DTAttributedTextContentView *)attributedTextContentView willDrawLayoutFrame:(DTCoreTextLayoutFrame *)layoutFrame inContext:(CGContextRef)context
Parameters
- attributedTextContentView
The content view that will be drawing a layout frame
- layoutFrame
The layout frame that will be drawn for
- context
The graphics context that will drawn into
Declared In
DTAttributedTextContentView.h