title: How to change hyper link text color in SwiftUI
body: <p>I am trying to custom change the default font color of hyperlink in a given markdown string with SwiftUI. Something equivalent to <code>txtString.linkTextAttributes = [ .foregroundColor: UIColor.red ]</code> of UIKit.
  Here's my code:</p>
  <pre><code>
  import SwiftUI
  
  struct TextViewAttributedString: View {
      var markdownString: String
      var body: some View {
          Text(convertIntoAttributedString(markdownString:markdownString))
      }
      
      private func convertIntoAttributedString(markdownString: String) -&gt; AttributedString {
          guard var attributedString = try? AttributedString(
              markdown: markdownString,
              options: AttributedString.MarkdownParsingOptions(allowsExtendedAttributes: true,
                                                               interpretedSyntax: .inlineOnlyPreservingWhitespace))
          else {
              return AttributedString(markdownString)
          }
          attributedString.font = .custom(&quot;Times New Roman&quot;, size: 16, relativeTo: .body)
          
          let runs = attributedString.runs
          for run in runs {
              let range = run.range
              if let textStyle = run .inlinePresentationIntent {
                  if textStyle.contains(.stronglyEmphasized) { // .stronglyEmphasized is available
                      // change foreground color of bold text
                      attributedString[range].foregroundColor = .green
                  }
                  if textStyle.contains(.linkTextAttributes) { // compiler error since .linkTextAttributes not available
                      // change color here but .linkTextAttributes is not available in inlinePresentationIntent
                      // Any other way to change the hyperlink color?
                  }
              }
          }
          return attributedString
      }
  }
  </code></pre>
  <p>Example View where AttribtedString being used</p>
  <pre><code>import SwiftUI
  
  struct AttributedStringView: View {
      let text: String = &quot;**Bold** regular and _italic_ \nnewline\n[hyperlink](www.google.com)&quot;
      var body: some View {
          TextViewAttributedString(markdownString: text)
      }
  }
  
  struct AttributedStringView_Previews: PreviewProvider {
      static var previews: some View {
          AttributedStringView()
      }
  }
  
  </code></pre>
  <p>Result:
  <a href="https://i.stack.imgur.com/geesR.png" rel="nofollow noreferrer">Result Screen</a></p>
  <p>Reference Docs: <a href="https://developer.apple.com/documentation/foundation/attributedstring" rel="nofollow noreferrer">https://developer.apple.com/documentation/foundation/attributedstring</a>
  <a href="https://developer.apple.com/videos/play/wwdc2021/10109/" rel="nofollow noreferrer">https://developer.apple.com/videos/play/wwdc2021/10109/</a></p>