Permalink
Browse files

Options for HTML

Render HTML with options.
  • Loading branch information...
depl0y committed Feb 7, 2014
1 parent 33e3679 commit bfae5291a9f11fb6f0a5f18dc512481d5d3d6aa9
Showing with 16 additions and 2 deletions.
  1. +9 −0 Core/Source/DTAttributedTextCell.h
  2. +7 −2 Core/Source/DTAttributedTextCell.m
@@ -47,6 +47,15 @@
*/
- (void)setHTMLString:(NSString *)html;
+/**
+ This method allows to set HTML text directly as content of the receiver.
+
+ This will be converted to an attributed string.
+ @param html The HTML string to set as the receiver's text content
+ @param options The options used for rendering the HTML
+ */
+- (void) setHTMLString:(NSString *)html options:(NSDictionary*) options;
+
/**
@name Getting Information
@@ -194,7 +194,11 @@ - (void)setSelected:(BOOL)selected animated:(BOOL)animated
- (void)setHTMLString:(NSString *)html
{
- // we don't preserve the html but compare it's hash
+ [self setHTMLString:html options:nil];
+}
+
+- (void) setHTMLString:(NSString *)html options:(NSDictionary*) options {
+
NSUInteger newHash = [html hash];
if (newHash == _htmlHash)
@@ -205,10 +209,11 @@ - (void)setHTMLString:(NSString *)html
_htmlHash = newHash;
NSData *data = [html dataUsingEncoding:NSUTF8StringEncoding];
- NSAttributedString *string = [[NSAttributedString alloc] initWithHTMLData:data documentAttributes:NULL];
+ NSAttributedString *string = [[NSAttributedString alloc] initWithHTMLData:data options:options documentAttributes:NULL];
self.attributedString = string;
[self setNeedsLayout];
+
}
- (void)setAttributedString:(NSAttributedString *)attributedString

0 comments on commit bfae529

Please sign in to comment.