NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

SOLVED: Is there a way to easily display rich text in SwiftUI?

Forums > SwiftUI

I am displaying a multiline text in a Text component. Ideally, I'd prefer some lines to be shown bold, like they are headers. I made a search and only found advice which was rather old. So far, I will probably go the RichText custom component way (https://github.com/NuPlay/RichText).

However, displaying rich text is such a basic thing, and it existed in UIKit. So I am thinking maybe in the most up-to-date version of SwiftUI this was already made possible, and I simply was unable to find that?

   

You may want to look at the inline text markdown options that were introduced in iOS15.

WWDC21 Video

See if it will be enough for you.

1      

Thank you, it was a useful pointer. From those videos I understood that Markdown support does exist. But the answer how to enable it I found here: https://www.hackingwithswift.com/quick-start/swiftui/how-to-render-markdown-content-in-text

   

Alex seeks to use Markdown, but missed an opportunity in his last post!

Adding URLs to Forum Posts


You can add Markdown links to your Hacking With Swift forum posts! This allows you to hide the full URL, and provide an easy-to-read description.

Whilst composing your response, place the link's description inside a pair of square brackets:

// The description is inside the square brackets...
See -> [Enable Markdown in XCode]

Immediately after the square brackets, embed the URL inside of parenthesis:

// The URL is inside the parenthesis right after the description...
See -> [Enable Markdown in XCode](https://www.hackingwithswift.com/quick-start/swiftui/how-to-render-markdown-content-in-text)

When rendered in Markdown, you see the description, but the URL is hidden.
You get a simple, cleaner link for your readers.
Like this....

See -> Enable Markdown in XCode

   

Hacking with Swift is sponsored by Essential Developer

SPONSORED From March 20th to 26th, you can join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer!

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.