'How to animate the page change with TabView on SwiftUI
I'm trying to create a TabView and it works fine, but I would like to animate the view change, but all I could find is to animate with the PageTabViewStyle, but it makes the screen draggable, which is something I don't want to. I think I could remove this gesture, but the tabView gets tiny, as the iOS Home Screen indicators.
So, basically I would like to change the animation between the Views, here's my current code:
struct MainView: View {
@State private var selectedTab = 0
private var pageTitles = ["Home", "Home2"]
var body: some View {
TabView(selection: $selectedTab) {
HomeView(test: .green)
.tabItem {
Image(systemName: "house.fill")
Text("Home")
}.tag(0)
HomeView(test: .blue)
.tabItem {
Image(systemName: "house.fill")
Text("Home2")
}.tag(1)
}
.navigationTitle(Text(pageTitles[selectedTab]))
.navigationBarTitleDisplayMode(.inline)
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
