I have a SwiftUI
View that looks like the following:
import SwiftUI
struct ContentView: View {
var body: some View {
HStack(alignment: .top) {
VStack(alignment: .leading) {
HStack {
Image(systemName: "star.fill")
.aspectRatio(contentMode: .fit)
.frame(width: 16, height: 16)
Text("Speed")
}.padding(.bottom, 10)
HStack {
Image(systemName: "star.fill")
.aspectRatio(contentMode: .fit)
.frame(width: 16, height: 16)
Text("Distance")
}
Spacer()
}
Spacer()
}
}
}
This looks like the following in the preview.
I want to add a border left of a black line to the VStack
containing the Text
and Image
. In css I would do something like border-left: 1px solid black
Does anyone have an idea of how to do this in SwiftUI?
2
Answers
As I mentioned in comment, the existing solution gives you some good options. A really hacky way would be like this:
For me I actually will code like this to get the view:
The Result:
But I’m not sure if this is what you want or not, but if this help I’m happy.