Better Programming

Advice for programmers.

Follow publication

Member-only story

iOS 15 Brings Attributed Strings to SwiftUI

Markdown, colors, and formatting — it’s never been easier

Andrew Zheng
Better Programming
Published in
3 min readJun 8, 2021

--

Image Credit: author

Attributed Strings have always been hard to work with. The most basic implementation, in UIKit, would be something like this:

This is bad enough, but it’s even worse for SwiftUI. The current accepted answer on Stack Overflow uses UIViewRepresentable and some other unnecessarily complex code. However, that was the only way — until WWDC21.

Markdown

Markdown is everywhere: on GitHub, Stack Overflow, Discord’s message bubble… and now, the awesome formatting language comes to SwiftUI! Everything works, even links:

--

--

Andrew Zheng
Andrew Zheng

Written by Andrew Zheng

WWDC21 Scholar. I like to read manga and write about Swift. Check out my app, Find — look for text in real life, with outrageous speed. getfind.app

Responses (3)

Write a response