I wish to add a customized transition between pages. I’ve this code
struct ContentView: View {
@State var currentPage = 0
var physique: some View {
ZStack {
TabView(choice: $currentPage) {
Coloration.pink
.tag(0)
Coloration.yellow
.tag(1)
Coloration.purple
.tag(2)
Coloration.cyan
.tag(3)
}
.tabViewStyle(.web page(indexDisplayMode: .by no means))
.animation(.easeOut(period: 0.3), worth: currentPage)
Button(motion: {
currentPage = currentPage + 1 > 3 ? 0 : currentPage + 1
}, label: {
Textual content("Change Web page")
})
.buttonStyle(.borderedProminent)
}
}
}
Appears to be like just like the .animation(.easeOut(period: 0.3), worth: currentPage)
would not make any distinction in transitioning from one web page to a different in a TabView
utilizing PageTabViewStyle
. The animation that I get is at all times the default
animation. I would like the web page swap to be clean.
On this gif we will see that web page swap would not interpolate like an easeOut
curve. Something that I put within the .animation
modifier would not have an effect on the transition. Neither period or curve kind.
I already tried to make use of the withAnimation
block contained in the button motion however would not have an effect on the transition as nicely.
Has anybody with the ability to customise the web page swap utilizing a TabView
in SwiftUI
?