grid and buttons

I would like to create 5 buttons in two rows the first row contains 3 buttons while the second 2 buttons button D should occupy the space occupied by the two buttons at the top A and B while as you can see from the attached image button D is as wide as the others on visualstudio c# I know how to do it but with Xcode Swift I can't find any documentation that can help me

Welcome to the forum

It's difficult to understand what is the problem.

 

D should occupy the space occupied by the two buttons at the top A and B

What does it mean ? That's not what the drawing shows

Anyway, looking at the drawing, you have several ways:

  • if you use storyboard (UIKit), it is very easy to position the buttons in a view, either in absolute coordinates or with constraints settings.
  • you can also create buttons in code setting the correct frame
  • you could also use a grid, but it is over complex for such a simple thing
  • If you use SwiftUI , you create 2 HStacks, containing A, B, C and the second D, E ; then you encapsulate them in a VStack ; code would look like
VStack {
  Spacer()

  HStack {
     Spacer()
     Button { A }
     Spacer()
     Button { B }
     Spacer()
     Button { C }
     Spacer()
  }

  Spacer()

  HStack {
     Spacer()
     Button { D }
     Spacer()
     Button { E }
     Spacer()
  }

  Spacer()
}

So please explain clearly what you do not know how to do.

this is what i would like to achieve, button D should have the width of buttons A and B

Seems like a job for Grid multicolumn cells!

I had already tried to use the grid like the example you indicated but the graphic response is not what I would like to achieve

grid and buttons
 
 
Q