Group Group Group Group Group Group Group Group Group

Chapter 3: HeaderView Preview needs dark `background`

Hi team!,

First of all amazing work with the book really didactic, I just have an small concern, such I mentioned on the title I’m on Chapter 3: Working with Previews, just on this part…

Set Color Scheme to Dark and Dynamic Type to accessibilityLarge.

Everything worked fine except the dark mode, for some reason I just had a white rectangle, I added the following modifier .background(Color(UIColor.systemBackground)) and now I’m able to see my Header.

Did I have to do something before, so I don’t need to add the .background modifier?


hi Juan! You shouldn’t need to specify the background color. The code uses standard system everything, so it should just work.

Your code looks like this?

VStack {
  HStack {
    Image(systemName: "")
    Image(systemName: "")
    Image(systemName: "")
    Image(systemName: "")

Try opening the final project for the chapter and see if it works.

1 Like

Hey @audrey thanks for the response, I already saw my issue (checking the final project for the chapter), my code was exactly the same, but the issue was on my preview code instead using the attributes inspector I wrote the modifier for color scheme and I didn’t notice that there were a colorScheme(_ colorScheme:) and preferredColorScheme(_ colorScheme:), I was using the first one :man_facepalming:


Thanks Juan, that’s useful for us to know!