In #SwiftUI we have a convenient way to set a view's background to a shape, like a capsule or rounded rectangle, using the background(_:in:) modifier.
This works great when we need to place a single shape behind a view: https://nilcoalescing.com/blog/SetAShapeAsBackgroundInSwiftUI/
This works great when we need to place a single shape behind a view: https://nilcoalescing.com/blog/SetAShapeAsBackgroundInSwiftUI/
Comments
.background{Capsule().fill(Color.yellow.gradient)}
One of the things I’ve found confusing about learning SwiftUI is how many different overloads there are, ways of achieving the same thing with v small differences.