Is there any trick so i can give html formatted text to e.g. UILabel or UITextField and iphone will format the text accordingly?
For example if there is a bold tag, the text will be bolded.
Is there any trick so i can give html formatted text to e.g. UILabel or UITextField and iphone will format the text accordingly?
For example if there is a bold tag, the text will be bolded.
You can try with NSAttributedString
label.attributedText =
[[NSAttributedString alloc]
initWithData: [html dataUsingEncoding:NSUTF8StringEncoding]
options: @{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType }
documentAttributes: nil
error: &err];
No, the only class I know in iOS that displays HTML is UIWebView. Of course, you can use a small web view to display some HTML to get text styles. But if you're only want to draw static styled text in a view you can use CoreText. There are many examples out there (including one from Apple called CoreTextPageViewer) of how to draw an NSAttributedString with CoreText.
Hope that helps!
try with NSAttributedString.
https://nodeload.github.com/AliSoftware/OHAttributedLabel/zipball/master
inthis example ,they show on UILable
Only UIWebView supports html but you should also checkout this repo on github -
i think it is better way display HTML content in UIwebview compare to handle in other component
Take a look at HTML String content for UILabel and TextView Where he mentions about "Three20 project which includes a class TTStyledTextLabel which allows you to render HtmL-Code and even activates links"
Short answer, no.
To display HTML you need to use a UIWebView. If you want a rich text editor then you need to look at 3rd party Such as three20. Or on iOS > 4 you can use contentEditable in a UIWebView