moobi
moobi

Reputation: 8449

Two Buttons. Above each other. Over whole screen

I just like two buttons above each other with no margins. This seems like an easy task, but I am new to iOS and I wasted too much time now. I tried dozens of contraints but it never went out well. I always ended up with setting the leading Spaces to -24 and having marings above and beneath the buttons. I am using xcode6, iOS8.1 and storyboard. My app is landscape only. Can someone please teach me what to do?

The buttons should look like seen in this picture: Fullscreen, no margins and Button1 should reach unter the statusbar!enter image description here

Upvotes: 0

Views: 209

Answers (1)

chris
chris

Reputation: 4996

I'll outline the steps:

  • Pin Button 1 to 0 spacing on Left, Right, Top
  • Pin Button 2 to 0 spacing on Left, Right, Bottom
  • Select both buttons, then Pin heights equally

(You can access pin either from the Editor tool bar in the top menu, or from the second icon in the constraints area)

enter image description here

The thing with constraints and auto layout is that you only need enough constraints to let the app calculate where elements should be at all times. You might be able to get away with less constraints.

To get remove the borders, you need to change the button Type in IB from System to Custom, then you can drag and alter the margins to remove them. Following that you will need to update constraints on the buttons.

Upvotes: 2

Related Questions