|
Hi All, I wonder if anyone can help me with a problem that's currently evading a solution for me. Basically I have a view shown in a sheet with a headline at the top of the view, I would like to use a GeometryReader to turn a section of text blue once the headline disappears out of view, however, different devices produce different starting minY values and I am assuming this is because of the location that the sheet is displayed on the screen however this means that its become almost impossible for me to hardcode a figure or even calculate a figure to indicate when the headline is no longer in view. Is there a way of achieving this at all please? I am not aware of any other way of detecting a scroll position without using a GeometryReader however if there is one I'll happily use that. Below is a simple mock-up of what I am trying to achieve, the bottom paragraph of text will turn blue once the header has scrolled out of view, I have used an iPhone mini as the initial starting point however any solution needs to work on all devices.
Thank you in advance for any help anyone can give! |
|
Hi, try with this, it should give you an offset of -0.0 on all devices,
|
|
@Hectorcrdna, you are a life saver, thank you! Initially I was using a PreferenceKey in my code I just simplified it for my code example and my strugle came from getting a zero point and I tried everthing, I never thought of using a named name space! Thank you again @Hectorcrdna! |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.