Skip to content

Instantly share code, notes, and snippets.

@lucianoschillagi
Created December 17, 2023 16:25
Show Gist options
  • Save lucianoschillagi/ec3f82b8cb846f4f593fa018569ecf8b to your computer and use it in GitHub Desktop.
Save lucianoschillagi/ec3f82b8cb846f4f593fa018569ecf8b to your computer and use it in GitHub Desktop.
Formatting Text with Markdown in SwiftUI
import SwiftUI
struct TextWithMarkdown: View {
var body: some View {
ZStack {
Color.yellow.opacity(0.7).ignoresSafeArea()
VStack(alignment: .leading) {
// Basic Text:
Text("Hello, SwiftUI!").padding()
// Text with Formatting:
Text("This is *italic* and this is **bold**.").padding()
// Multiline Text:
Text("""
This is a multiline text
with multiple lines.
""").padding()
// Strikethrough Text:
Text(" This text is ~~strikethrough~~.")
.strikethrough()
// Text with Links:
Text("Visit [Apple's website](https://www.apple.com)")
.padding()
.underline()
.foregroundColor(.blue)
}.font(.title)
}
}
}
#Preview {
TextWithMarkdown()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment