[ad_1]
I have been utilizing an uneven transition which has been working flawlessly in the course of the time of iOS 15. Nevertheless, with the introduction of iOS 16 the transition now not works as anticipated.
Briefly: In my app I am utilizing a paged tabview. While you swipe pages I need to insert/take away one other view with an animation/transition, matching the web page swipe course.
Because it’s a lot simpler to explain the issue in code I’ve created an remoted case the place my downside is repeatable, so you’ll be able to see it for your self.
import SwiftUI
class SharedStore: ObservableObject {
@Printed var selectedPage: Int = 0 {
willSet {
if newValue > selectedPage {
self.pageDirection = .ahead
} else {
self.pageDirection = .reverse
}
}
}
var pageDirection: UIPageViewController.NavigationDirection = .ahead
}
struct ContentView: View {
@StateObject var sharedStore = SharedStore()
var physique: some View {
VStack {
Textual content("Web page (sharedStore.selectedPage)")
.id(sharedStore.selectedPage)
.body(maxWidth: UIScreen.primary.bounds.width)
.animation(.easeInOut, worth: sharedStore.selectedPage)
.transition(
.uneven(
insertion: .transfer(edge: sharedStore.pageDirection == .ahead ? .trailing : .main),
removing: .transfer(edge: sharedStore.pageDirection == .ahead ? .main : .trailing)
)
)
TabView(choice: $sharedStore.selectedPage) {
ForEach(0..<10, id:.self) { index in
Textual content("Hey (index)")
}
}
.tabViewStyle(.web page)
}
.padding()
}
}
Run the above on a iOS 16 simulator. Swipe a few pages after which change course. Discover that the transition of the highest view will get bizarre. The view is eliminated and inserted from the identical edge.
In case you nevertheless run the identical code on a iOS 15 simulator, you will notice that the highest view animation matches the web page swipe course properly, even once you change course.
My assumption is that one thing has modified with the uneven transitions in SwiftUI 4 / iOS 16, therefore the title of the query. Or may or not it’s one thing the revealed property and the willSet observer?
Observe that I am removed from knowledgeable iOS developer, so I am additionally contemplating that this really labored in iOS 15 by pure luck 🙂
[ad_2]
