G
G
Gorus132015-09-24 17:38:52
Objective-C
Gorus13, 2015-09-24 17:38:52

NSAttributedString and blockquote. How to do?

How to make blockquote map to NSAttributedString ?
Style "border-left:3px solid black;" does not work in UITextField.

NSString *testString = @"<style>\n"
            ".quote {\n"
            "border-left:3px solid black;\n"
            "}\n"
            "</style>\n"
            "<body>\n"
            "    <div class=\"quote\"><div>This is a quote</div></div>\n"
            "  <br/>\n"
            "  Bla bla bla\n"
            "</body>";

NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:[testString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];

self.messageLabel.attributedText = attributedString;

ps
Do not offer UIWebView, because you need the ability to edit text.

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
S
smanioso, 2015-09-26
@smanioso

TextKit - https://developer.apple.com/library/ios/documentat...
Or look for a ready-made library with the required functionality.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question