Dan*_*Dan 6 string-concatenation swiftui
试图实现类似 Tinder 的条款和条件之类的功能,但是我不知道如何使条款和隐私政策在 swift UI 中可点击

创建帐户或登录即表示您同意我们的条款和隐私政策
var body: some View {
Text(Constants.privacyText)
.applyCustomLabelTextProperties(size: size, kerning: 2)
.foregroundColor(color)
// .lineLimit(2)
+
Text(" ")
+
Text(Constants.terms).underline()
.foregroundColor(color)
// .onTapGesture {
// print("test")
// }
+
Text(" and ")
.foregroundColor(color)
+
Text(Constants.privacyPolicy).underline()
.foregroundColor(color)
}
}
Run Code Online (Sandbox Code Playgroud)
尝试在 Text() 上应用可点击的 .onTapGesture 并尝试添加一个按钮并将其连接到文本中,但也没有成功。
已经太晚了,但如果这对某人有帮助,那么我很高兴:)
尝试这个,
var body: some View {
VStack {
Text("By creating an account you agree to our ")
HStack {
Button(action: { }){ Text("Terms").underline() }
Text(" and ")
Button(action: { }){ Text("Privacy Policy").underline()}
}
}
}
Run Code Online (Sandbox Code Playgroud)
结果:
| 归档时间: |
|
| 查看次数: |
6598 次 |
| 最近记录: |