Fetching contributors…
Cannot retrieve contributors at this time
41 lines (35 sloc) 1.5 KB
pre { color:gray; }
<h2>Custom Objects</h2>
<p>This demonstrates usage of the &lt;object&gt; tag for embedding your own views</p>
<p><object style="display:inline;margin-bottom:1em;" someColorParameter="red" width=100 height=20></object>
or <object style="display:inline;margin-bottom:1em;" someColorParameter="green" width=100 height=20></object></p>
<p>These views are writting in HTML like this:</p>
<pre>&lt;object style="display:inline;margin-bottom:1em;" someColorParameter="red" width=100 height=20&gt;&lt;/object&gt;</pre>
<p>You provide your own custom view in the <b>-attributedTextContentView:viewForAttachment:frame:</b> method.</p>
<pre>if (attachment isKindOfClass:[DTTextAttachmentObject class])
// somecolorparameter has a HTML color
UIColor *someColor = [UIColor colorWithHTMLName:[attachment.attributes objectForKey:@"somecolorparameter"]];
UIView *someView = [[UIView alloc] initWithFrame:frame];
someView.backgroundColor = someColor;
someView.layer.borderWidth = 1;
someView.layer.borderColor = [UIColor blackColor].CGColor;
return someView;
<p>Object tags can access their childNodes</p>
&lt;object height=100 width=100&gt;
&lt;special stuff="bla" /&gt;
<object height=100 width=100>
<special stuff="bla" />
<p>When creating the custom view for this object you access the text attachment childNodes to get special information you have put there in addition to the attributes</p>