小编Fad*_*y E的帖子

Gap in HStack between two views in SwiftUI

I am trying to have two views in an HStack using SwiftUI. However, I keep getting a gap between the two views. The problem occurs in both portrait and landscape layouts.

my code:

struct ContentView: View {

    var body: some View {

        GeometryReader { g in
            HStack {
                GeometryReader { g in
                    HStack {
                        VStack {
                            Text("View One")
                        }
                        .frame(width: g.size.width * 0.5, height: g.size.height, alignment: .center)
                        .background(Color.blue)

                        VStack {
                            Text("View Two")
                        }
                        .frame(width: g.size.width * 0.5, height: g.size.height, alignment: …
Run Code Online (Sandbox Code Playgroud)

swift swiftui

1
推荐指数
1
解决办法
55
查看次数

标签 统计

swift ×1

swiftui ×1