I’m about to finish chapter 7 and my Bullseye app is working great. I’ve been fiddling around with some code to get a better idea of how things work and I’m confused about calling background(). The developer documentation didn’t help me.
For the vertical stack we call this:
.background(Image(“Background”))
That makes the background image completely fill the entire screen, including around the notch in the simulated iPhone 11.
However, I’m confused about the result when I change the line to read this instead:
.background(Color.blue)
Why does the background suddenly not fill the entire screen?
Looks like it’s more of an AutoLayout constraint issue. Seems like when the image background is large enough, it will automatically fit itself and expands the UIImageView, however when you set it to background color to blue, now it uses its set width & height.
Can you try playing around with the constraint layout of the UIImageView?
I’d know how to do that with UIKit, but not with SwitftUI at this point in the lessons. Don’t worry about it, I was just curious why it was behaving this way. Thanks for the info.