On few screens of my SwiftUI app I am using Divider() between few elements. This Divider is rendered as a very thin grey (or black?) line. I am guessing 1 point. How can I change the width of Divider()?
How to Add Vertical Divider: VerticalDivider( color: Colors. black, //color of divider width: 10, //width space of divider thickness: 3, //thickness of divier line indent: 10, //Spacing at the top of divider. endIndent: 10, //Spacing at the bottom of divider. )
A divider in SwiftUI is an easy and concise way to help separate content within a view.
If the canvas isn't visible, select Editor > Editor and Canvas to show it. The Horizontal Divider is displayed as a horizontal line to divide views. Inside a HStack the divider is displayed as a vertical line. The size of the divider can be changed with the frame modifier.
You can create any divider you wish, colors, width, content... As in below example.
struct ExDivider: View {
let color: Color = .gray
let width: CGFloat = 2
var body: some View {
Rectangle()
.fill(color)
.frame(height: width)
.edgesIgnoringSafeArea(.horizontal)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With