Created
December 17, 2023 16:25
-
-
Save lucianoschillagi/ec3f82b8cb846f4f593fa018569ecf8b to your computer and use it in GitHub Desktop.
Formatting Text with Markdown in SwiftUI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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