4 ms·
"there must be an iOS equivalent of the <strong> tag, right? Apparently not." It's not a silver bullet (it can sometimes give you a bit of a performance hit),
by lazerwalker 14y ago
"there must be an iOS equivalent of the <strong> tag, right? Apparently not."
It's not a silver bullet (it can sometimes give you a bit of a performance hit), but the Nimbus library has a UILabel subclass that makes bolding a substring a lot less painful than manual NSAttributedString munging: http://docs.nimbuskit.info/group___nimbus_attributed_label.html http://docs.nimbuskit.info/group___nimbus_attributed_label.h...
- staufman 14y agoAgreed. I actually wrapped this library with a simple HTML parser that can understand basic tags (<strong>, <b>, <a>, etc.) and translate them into calls to Nimbus. At some point, I'd love to incorporate a Fireball markdown parser so that authored and styled content from our servers can just be pulled from our app.
- SeoxyS 14y agoYou might be interested in something I plan to open source at some point: a native Markdown lexing / parsing engine meant to be used to stylize markdown for Core Text / NSAttributedString. Here's the meat of it in a gist: https://gist.github.com/29dabe4b6e762ee221df https://gist.github.com/29dabe4b6e762ee221df
- andrew_k 14y agoThanks a lot for the link, I was going to write Markdown -> NSAttributedString library myself, because I couldn't find one. Right now I'm just using DTCoreText and convert Markdown to HTML on the server.
- SeoxyS 14y agoYou might also want to look into GitHub's Sundown library. It's an awesome library and being written in pure C, you can use it natively. The reason I wrote myself is that my use case was more markdown highlighting than markdown parsing. I needed to preserve the markdown source untouched, which Sundown doesn't support. https://github.com/vmg/sundown https://github.com/vmg/sundown
- michaelmior 14y agoI found NIAttributedLabel to work quite nicely for this and it's pretty straightforward.
- Lalabadie 14y agoThe typical solution where I work is, if I recall correctly, a TTTAttributedLabel: https://github.com/mattt/TTTAttributedLabel https://github.com/mattt/TTTAttributedLabel