BLACK FRIDAY 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?

   

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 Guardsquare

SPONSORED AppSweep by Guardsquare helps developers automate the mobile app security testing process with fast, free scans. By using AppSweep’s actionable recommendations, developers can improve the security posture of their apps in accordance with security standards like OWASP.

Learn more

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

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.