Software Alternatives & Reviews

Easy Way to Display Markdown in SwiftUI using Text

Apple
  1. SwiftUI is an innovative, exceptionally simple way to build user interfaces across all Apple platforms with the power of Swift.
    Struct ContentView: View { @State private var text: String = " **SwiftUI** helps you build great-looking apps across all _Apple_ platforms with the power of Swift — and surprisingly little code. You can bring even better experiences to everyone, on any Apple device, using just one set of tools and APIs.[SwiftUI](https://developer.apple.com/xcode/swiftui/)" // declare variable as LocalizeStringKey instead @State private var localizeText: LocalizedStringKey = " **SwiftUI** helps you build great-looking apps across all _Apple_ platforms with the power of Swift — and surprisingly little code. You can bring even better experiences to everyone, on any Apple device, using just one set of tools and APIs.[SwiftUI](https://developer.apple.com/xcode/swiftui/)" var body: some View { VStack { // convert String to LocalizedStringKey first Text(LocalizedStringKey(text)) Divider() Text(localizeText) } .padding() } }.

    #Development Tools #JavaScript Framework #Javascript UI Libraries 23 social mentions

  2. 2
    Available on iOS
    Struct ContentView: View { private var attrText: AttributedString { do { var text = try AttributedString( markdown: " **SwiftUI** helps you build great-looking apps across all _[Apple](https://apple.com)_ platforms with the power of Swift — and surprisingly little code. You can bring even better experiences to everyone, on any ~Apple device~, using just one set of tools and APIs." ) if let range = text.range(of: "SwiftUI") { text[range].backgroundColor = .yellow text[range].foregroundColor = .red } if let range = text.range(of: "Apple") { text[range].foregroundColor = .purple text[range].font = .system(size: 30) } if let range = text.range(of: "Apple device") { text[range].backgroundColor = .red text[range].foregroundColor = .white text[range].font = .boldSystemFont(ofSize: 25) } return text } catch { return "Error text attribute" } } var body: some View { VStack { Text(attrText) } .padding() } }.

    #Hardware #Music #Music Promotion 64 social mentions

Discuss: Easy Way to Display Markdown in SwiftUI using Text

Log in or Post with