/
Objects.html
28 lines (25 loc) · 1.11 KB
/
Objects.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<html>
<head>
<style>
pre { color:gray; }
</style>
</head>
<body>
<h2>Custom Objects</h2>
<p>This demonstrates usage of the <object> 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><object style="display:inline;margin-bottom:1em;" someColorParameter="red" width=100 height=20></object></pre>
<p>You provide your own custom view in the <b>-attributedTextContentView:viewForAttachment:frame:</b> method.</p>
<pre>if (attachment.contentType == DTTextAttachmentTypeObject)
{
// 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;
}</pre>
</body>