我通过参考https://developer.apple.com/documentation/swiftui/tabviewTabbedView
使用SwiftUI
框架来实现
在模拟器上运行时,只有第一个选项卡视图内容显示,其他选项卡内容不显示。即使在重新启动 XCode、模拟器等之后。
应用视频链接:https ://youtu.be/Gibu8jfQQ5I
struct ContentView : View {
var body: some View {
TabbedView {
Text("The First Tab")
.tabItem {
Image(systemName: "1.square.fill")
Text("First")
}
Text("Another Tab")
.tabItem {
Image(systemName: "2.square.fill")
Text("Second")
}
Text("The Last Tab")
.tabItem {
Image(systemName: "3.square.fill")
Text("Third")
}
}.font(.headline)
}
}
感谢您的帮助和建议!