I have added the borders for all sides using code below in SwiftUI
Rectangle()
.overlay(Rectangle()
.fill(Color.white).padding(2))
.foregroundColor(Color.red)
How to add a border for specific sides of Rectangle?
I have added the borders for all sides using code below in SwiftUI
Rectangle()
.overlay(Rectangle()
.fill(Color.white).padding(2))
.foregroundColor(Color.red)
How to add a border for specific sides of Rectangle?
The solution in this case is to use explicitly specified edges to which padding is applied
Rectangle()
.overlay(Rectangle()
.fill(Color.white).padding([.leading, .trailing], 2)) // << here !!
.foregroundColor(Color.red)