itarato
itarato

Reputation: 865

How to rearrange a constraint in iOS?

In XCode I'm working on a small view I use on several screens:

enter image description here

There is the black bar on the top. By default it has 2 constraints that defines a static distance between the bottom of the bar and the bottom of the view. So if I load this view on a large screen the top bar will be stretched out. I would like keep it fixed height and want to stretch the view in the center instead.

I've tried to delete the 2 constraints but they were re-created immediately. Also tried to set their value to 'auto' but that did not help either.

How can keep the top bar fixed and stick to the top - and having the view in the center dynamic height?

Upvotes: 0

Views: 633

Answers (1)

bvogelzang
bvogelzang

Reputation: 1415

You'll want to add two new constraints. One that sets the top space of the top bar to superview and one that sets the height of the top bar. Once you add these constraints you should be able to remove the other two that are causing this issue. You can add these constraints using the middle button (pin) in the bottom right hand corner of the storyboard window:

enter image description here

Upvotes: 1

Related Questions