|
Hi ! I am trying to get the background image of the ZStack to arrive to the top of the screen. I am using .frame(maxWidth: .infinity, maxHeight: .infinity) to get it. But it doesn't appear like that. The top of the screen is still white... What am I doing wrong ? how could I get it?
|
|
I think it's called the safe area..... https://www.hackingwithswift.com/quick-start/swiftui/how-to-inset-the-safe-area-with-custom-content |
|
|
|
@GeorgeMCSwifter I think .safeAreaInset() is to get the image just in the safe area, isn't it? but that is not what I am looking for... @NigelGee I have tried with .ignoresSafeArea() after .scaledToFill() but it doesn´t fill the top of the screen with the image... |
|
If you are using PS this is not in a |
|
You mena changing .scaledToFill for ScaledToFit() ? If I use .scaledToFit() the problem is still there... I don't understand what you mean with "this is not in a NavigationStack that may not help as the title bar is on top of the ZStack". I have 't put a title yet... |
|
|
|
@Kitty2018 the link I posted specifically states ignoresafearea() in the first paragraph. The rest is what youll probably need if you want to customize top and bottom. One way to troubleshoot is to create a basic program and make sure everything works as it should. Then start cross referencing your code. i have a program named playground that i go back to every now and then to load some code /troubleshoot. Maybe look up troubleshooting swift programs might also help you. i think this runs along the lines of teach a man to fish he will be fed for a lifetime etc etc Best of luck! |
|
I have added the .ignoreSafeArea() modifier to the scrollView instead to the background Image and it works perfect now!!! |
SPONSORED Alex is the iOS & Mac developer’s ultimate AI assistant. It integrates with Xcode, offering a best-in-class Swift coding agent. Generate modern SwiftUI from images. Fast-apply suggestions from Claude 3.5 Sonnet, o3-mini, and DeepSeek R1. Autofix Swift 6 errors and warnings. And so much more. Start your 7-day free trial today!
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.