|
Hi, I have an Horizontal Scroll View which displays 3 cards, below it I have a list of related infos. When scrolling the cards, how can I detect which card is currently displayed on screen in order to show the related and correct infos? Thanks |
|
I added a tap gesture on the card so, when I click one, it automatically updates the list with the relevant infos. But I can't figure it out how to detect which card is currently on screen. Maybe I have to calculate it using geometry reader or similar? Any suggestion? Thanks |
|
Hi! Maybe as an easier option for you to use TabView like so.
Well if it fits your purpose and design of course... |
|
If you still need to use ScrollView here is a good example. A bit verbose piece of code though... Credits to Daniel Saidi, cannot post link. Seems like too many spammers so HWS rejects insertion of some links now...
|
|
Thank you so much! I think the TabView solution is more natural using SwiftUI, it makes the code more easier and readable. |
TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and more!
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.