|
I have a ScrollView that's full of views that each have their own unique background colour. This works great in every orientation except iPhones with FaceID in landscape orientation. In this one particular case, I can't find a way to avoid showing the ScrollView's background. Any ideas for how I can play with safe area insets such that I can get the unique background colours to go the full width of the screen? This is a simplified version of what I'm working with in my app.
Things I've tried:
Any help would be greatly appreciated! |
|
Hi Matthew I didn't find a simple solution with a single modifier... so you could consider my solution like "cheating". The idea is to allow the I hope this solves also your problem. Philipp
|
|
Thanks Philipp! This is twice now you've swooped in with awesome solutions for me :) I really appreciate it!! Your GeometryReader solution works great. I had been looking for something with safe area insets, but unfortunately I couldn't get the modifiers @twostraws describes here to work properly. I didn't know that GeometryReader provided that kind of info (and frankly wouldn't have thought to use it like that even if I did lol), but I think it's as elegant a solution as SwiftUI has for most things. Before I saw your answer, I came up with a super ugly hack that kind of worked that I'll share here in case it helps someone else solve a different kind of problem. It uses GeometryReader in the background to determine if the view is in landscape, and if so, applies conditional padding. Your solution is much cleaner and less fragile than this!
|
SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.
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.