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
版权声明:本文标题:swift - Navigation on substring swiftui - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736308115a1933547.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论