L. Sherbini
L. Sherbini

Reputation: 69

SwiftUI .background modifier isn't working

Is there a reason as to why the .background modifier on SwiftUI is not changing colors?

here

I tried restarting Xcode and even creating a new project and I'm still facing the same issue.

Upvotes: 1

Views: 896

Answers (2)

Asperi
Asperi

Reputation: 257711

By default Rectangle() has Color.black opaque foreground color, so any background will be invisible below it.

You can use instead

Rectangle().fill(Color.white)

or

Rectangle().foregroundColor(Color.white)

Upvotes: 1

magnuskahr
magnuskahr

Reputation: 1320

The background (around the rectangle) is white, try use .fill() instead

Upvotes: 0

Related Questions