【发布时间】:2020-11-19 03:49:57
【问题描述】:
在具有 PageTabViewStyle 的 TabView 的页面中,导航或 Button 的操作都不起作用。有人有任何想法或解决方法吗?复制代码:
var body: some View {
VStack {
TabView(selection: $selection) {
Button(action: {
print("First selected")
}){
Text("Fist")
}
.tag(0)
.buttonStyle(PlainButtonStyle()
Button(action: {
print("Second selected")
}){
Text("Second").tag(1)
}
.tag(1)
Button(action: {
print("Third selected")
}){
Text("Third")
}
.tag(2)
}
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .always))
.frame(width: 900, height: 400)
.background(Color.blue)
}
}
【问题讨论】:
-
如何把你的按钮放在一个 VStack 中