admin管理员组

文章数量:1122846

I want to implement a onTapGesture on multiple substrings of a string but keeping the whole text view appropiate. For example the String is, "By click on checkbox you agree to our terms of services, privacy policy ..." I want to implement properties such as underline, blue text and onTapGesture, so I can perform Navigation on its active value. How can I achieve that, keeping in my mind, I don't want text jumbled, the whole text should appear as one single text, I tried using concatenation property but, I often get compile errors in Xcode. I tried this approach as well

func combinedTexts: some View {
var texts = strings.map{Text($0)}
            texts[1] = texts[1].foregroundColor(.blue).underline()
            texts[3] = texts[3].foregroundColor(.blue).underline()
            texts[5] = texts[5].foregroundColor(.blue).underline()
            
          
            return texts[1...].reduce(texts[0], +)
}

But was not able to add the onTapGesture as it prompts,

Cannot assign value of some view to subscript of type 'Text'.

What could be the suitable solution for my problem? Thanks ahead!

本文标签: swiftNavigation on substring swiftuiStack Overflow