【发布时间】:2019-12-15 14:03:26
【问题描述】:
我想在 Game Center 设置中创建一个类似于 Apple 的 UI,其中文本末尾有一个可点击的链接:
我正在使用 SwiftUI。我尝试以多种方式结合Text 和Button:
Form {
Text("A social gaming service that lets you interact with friends, track and compare scores and achievements, challenge other players, and compete in mulitplayer games.")
Button("See how your data is managed...", action: {})
Button(action: {}, label: {
Text("A social gaming service that lets you interact with friends, track and compare scores and achievements, challenge other players, and compete in mulitplayer games.").foregroundColor(.black)
Text("See how your data is managed...")
})
Group {
Text("A social gaming service that lets you interact with friends, track and compare scores and achievements, challenge other players, and compete in mulitplayer games.")
Button("See how your data is managed...", action: {})
}
HStack {
Text("A social gaming service that lets you interact with friends, track and compare scores and achievements, challenge other players, and compete in mulitplayer games.")
Button("See how your data is managed...", action: {})
}
}
但是这些组合都不起作用:
我最好避免使用using an NSAttributedString,因为我想使用 SwiftUI 组件,并且只希望蓝色部分是可点击的。
如何将Button 附加到Text 以使其文本与文本的基线对齐?
【问题讨论】:
标签: swiftui