brianegge
brianegge

Reputation: 29872

Is there a simple way to create an NSAttributedString using markup on iOS?

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*"]; 

Upvotes: 2

Views: 1246

Answers (2)

sobri
sobri

Reputation: 1685

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

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

Upvotes: 1

Daij-Djan
Daij-Djan

Reputation: 50099

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

Upvotes: 1

Related Questions