2

I would simply to add bold or italic to portions of my text. Is there some built in parse that makes this simple, as most the examples I've seen show about a page worth of code, which requires doing substring range calculations on the string. Ideally, I could do something like this:

label.attributedText = [NSAttributedString initWithXXX:@"Some **bold** and *italic text*"]; 
1
  • There is no built in way. DTCoreText can generate an NSAttributedString from HTML but the last time I checked, it wasn't set up for UIKit (although it is not that hard to convert it yourself, it is all just changing the attribute key names from kCTwhatever to NSwhatever) Commented Nov 26, 2012 at 1:21

2 Answers 2

1

https://github.com/Cocoanetics/DTCoreText supports all the markup you can think of ^^

even css to NSAttributedString is possible.

See the attached Examples. It works fine with UIKit

Sign up to request clarification or add additional context in comments.

Comments

1

MGPushParser in MGBoxKit supports this for bold, italics, underlining, and monospacing, and coloured text.

"**bold**, //italics//, __underlined__, `monospaced`, and {#0000FF|blue}"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.