Issue #684

In SwiftUI, specifying maxWidth as .infinity means taking the whole available width of the container. If many children ask for max width, then they will be divided equally. This is similar to weight in LinearLayout in Android or css flex-grow property.

The same applies in vertical direct also.

struct ContentView: View {
    var body: some View {
        HStack(spacing: 0) {
            VStack {
                Spacer()
            }
            .frame(maxWidth: .infinity)
            .background(Color.red)

            VStack {
                Spacer()
            }
            .frame(maxWidth: .infinity)
            .background(Color.green)

            VStack {
                Spacer()
            }
            .frame(maxWidth: .infinity)
            .background(Color.blue)
        }
    }
}

width

Just Color

The above use VStack with an empty Spacer as an example. In practice, you can just use Color whose behavior is to take the same size as its parent.

struct ContentView: View {
    var body: some View {
        HStack(spacing: 0) {
            Color.red
            Color.green
            Color.blue
        }
    }
}