Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the padding above and below a SwiftUI Divider?

Right now, I have a VStack containing a Text, a HStack which contains a few more Texts, and a Divider between them. The problem is that the padding to the top and bottom of the Divider is too much on some smaller devices, making the result look odd. How can I decrease this padding (i.e. make the Texts to the top and bottom appear closer to the line)?

like image 405
jaltair9 Avatar asked Oct 26 '20 01:10

jaltair9


1 Answers

It is not a Divider reason, it is default spacing behavior of VStack, which applies different spacing between different subview types. To disable this make

VStack(spacing: 0) {  // or any other constant

and then apply any specific padding for any sub-view.

like image 162
Asperi Avatar answered Sep 30 '22 18:09

Asperi