如何使用swiftui创建此简单视图?

如何使用swiftui创建此简单视图?,swiftui,Swiftui,我正试图用swiftui做这个视图,但我被卡住了。 我希望文本(“Mesévènements”)居中,我希望它尽可能占据所有位置。 两条水平线只应位于左侧 我试过使用HStack,但无法使其按我所希望的方式工作。这里有一个可能的解决方案 struct ContentView: View { var body: some View { HStack{ VStack{ OrangeLine() } Text("Mes

我正试图用swiftui做这个视图,但我被卡住了。

我希望文本(“Mesévènements”)居中,我希望它尽可能占据所有位置。 两条水平线只应位于左侧

我试过使用HStack,但无法使其按我所希望的方式工作。

这里有一个可能的解决方案

struct ContentView: View {
var body: some View {
    HStack{
        VStack{
        OrangeLine()
        }
        Text("Mes évènements")
            .font(.subheadline)
            .fontWeight(.bold)
            .foregroundColor(Color.orange)
        VStack{
        OrangeLine()
        }
    }
}
}

struct OrangeLine: View {
    var body: some View {
        Rectangle()
            .fill(Color.orange)
            .frame(height: 2)
            .edgesIgnoringSafeArea(.horizontal)
    }
}

工作得很好!谢谢你!