iPhone app: How to display formatted text?
I need to display some simple formatted text inside a small section of a View. The background needs to be transparent because there's a background gradient image.
How I should I go about this? Maybe the Web View control will do the tri开发者_Go百科ck? thanks
A UIWebView
with a transparent background should do the trick, indeed. You could use something like:
UIWebView *formattedText = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 200, 50)];
[formattedText loadHTMLString:@"My <strong>formatted</strong> text" baseURL:nil];
Be careful though: UIWebView
s are heavy objects that suck a lot of memory, plus they may take some time to load and render your text. You should release your label as soon as you don't need it anymore.
UIWebView is heavy weight bloated stuff for this task. Stick with DTCoreText or if you're targeting iOS 6.0 you can use NSAttributedString.
精彩评论