WWDC24 SALE: Save 50% on all my Swift books and bundles! >>

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?

2      

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.

3      

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

2      

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

2      

Save 50% in my WWDC sale.

SAVE 50% To celebrate WWDC24, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.