どうも、ちょげ(@chogetarou)です。
TabViewのタブバーを非表示にする方法を紹介します。
方法
TabViewのタブバーを非表示にするには、UITabBarを使います。
具体的には、initメソッドやonAppear修飾子で、UITabBar.appearance().isHiddenにtrueを代入します。
init () {
UITabBar.appearance().isHidden = true
}
UITabBar.appearance().isHiddenにtrueを代入することで、TabViewのタブバーが非表示になります。
使用例
struct ContentView: View {
init() {
UITabBar.appearance().isHidden = true
}
var body: some View {
VStack {
TabView {
PageView(text: "Home View")
.tabItem {
Image(systemName: "house.fill")
Text("home")
}
PageView(text: "Data View")
.tabItem {
Image(systemName: "folder.fill")
Text("Data")
}
PageView(text: "Person View")
.tabItem {
Image(systemName: "person.fill")
Text("Person")
}
}
}
}
}
コメント