BugWarrior
BugWarrior

Reputation: 26

Swift Take a string, and return every string wrapped in "%%" bold, and everything else leave as is

I have a .txt file, and I have some words wrapped with "%%" on both sides (e.g. "My Regular text, and %%my Bold text%%"). I want it to return "My Regular text, andmy Bold text"

How would I set ALL wrapped text to be bold?

Upvotes: 0

Views: 233

Answers (1)

Fogmeister
Fogmeister

Reputation: 77651

A string of text does not in itself contain any formatting information. No fonts, no weights, no styles, etc...

What you are looking for is NSAttributedString. Using this you can then add attributes to substrings to add bolder text.

I believe it now supports markdown too so you can use double asterisks like this to make text bold without having to do much yourself.

I’ll find a link.

A popular iOS framework for Swift is Down https://github.com/iwasrobbed/Down

Upvotes: 1

Related Questions