0

I have Two Text views containing a bold part and a not bold part added by + operator in SwiftUI. Like Below:

Text(AppStrings.dummyName)
      .bold()
+ Text(" \(AppStrings.dummyMemberRequest)")

I want to turn the Bold part into a NavigationLink. But it is not possible as + Operator only works with Text view.

How can I turn a part of the Text view into a NavigationLink in SwiftUI, iOS 13?

Tanvirgeek
  • 540
  • 1
  • 9
  • 17
  • Does this answer your question? [SwiftUI tappable subtext](https://stackoverflow.com/questions/59624838/swiftui-tappable-subtext) – Phil Dukhov Sep 22 '21 at 13:00
  • No. I need a NavigationLink inside the app. Not a outside website link. – Tanvirgeek Sep 22 '21 at 14:07
  • The principe is the same. If you have single line text - just use `HStack`, otherwise you have to use `UIViewRepresentable` as shown in answers to that question, with an empty navigation link, which you will open using a state variable. – Phil Dukhov Sep 22 '21 at 14:24
  • @PhilipDukhov is correct. If you don't know how to trigger a `NavigationLink` in code, [see this answer](https://stackoverflow.com/a/63367285/7129318) – Yrb Sep 22 '21 at 14:36
  • https://stackoverflow.com/questions/67550392/how-can-i-create-text-in-swiftui-with-navigationlink-only-some-words-from-text/67551315#67551315 – lorem ipsum Sep 22 '21 at 15:34

1 Answers1

1

You can just use Markdown syntax instead of combining them like that

Text("This is a text with **bold** words")
Yousif Al-Raheem
  • 452
  • 5
  • 15