(2020) SwiftUI - Infinite Carousel (Inspired by the Health App) - 30 Minutes - Advanced
Why Stack Overflow recommends it
Stack Overflow users link it as a starting point when they need an infinite carousel or pager in pure SwiftUI, and as the tutorial they followed in their own carousel questions.
Recommended by 1 people across 1 different months, 2020 to 2020.
What it is
A 33-minute SwiftUI tutorial by ChrisLearns that builds an infinite carousel like the one in Apple's Health app, using ZStack, offsets and animation. The finished source code is available for download from the description.
What people said
Recommends nicksarno · 2020-12 · Stack Overflow · on “SwiftUI: stuck on infinite page view implementation”
I don't have an answer for your question, but I was trying to do a similar thing and ended up using the infinite carousel in this video ( [this video] ). He included a link to the source code in the description, which is pure SwiftUI (using ZStack/Offset/Animation). You could probably update the code pretty easily to make it a full screen pager.
Cites hippopop · 2020-03 · Stack Overflow · on “SwiftUI: Implementing Timer into CarouselView”
I followed this tutorial.. [this video] and I am trying to add timer to it as automatically go to the next image. Any suggestion? Thanks. This is my current code with some missing code and I don't know what to do next. import SwiftUI struct ContentView: View { let timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect() @State var Counter = 0 var body: some View { ZStack { VStack { Text("HELLOWORLD") VStack{ CarouselView(itemHeight: 400, views: [ AnyView(Text("1")), AnyView(Text("2")), AnyView(Text("3")), AnyView(Text("4")), AnyView(Text("5")), AnyView(Text("6")), ]).onReceive(timer) { _ in if self.Counter > 0 { self.Counter -= 1 //missing some code to move index of carousel to i+1 }
Cites adam.code · 2020-11 · Stack Overflow · on “SwiftUI - Navigation View opening with Back button and half grey screen / weird behavior”
I am trying to add navigation view to my app, but it is causing issues. My main UI is an infinitely swipe-able carousel of pages. It originally looks like this: [LINK] Then when I wrap it in a navigation view, it opens like this, with a back button and nothing else: [LINK] When I hit the back button, it looks like this: [LINK] The left side is swipe-able like the original UI, but when I touch the right, grey side, it takes me back to the empty page with the back button. Any idea what may be causing this? I implemented the infinite carousel by putting each page in a ZStack, and using offsets/relativeLocation. I referred to this tutorial: [this video] Can I not use a NavigationView? Is there an alt