Eamorr
Eamorr

Reputation: 10012

Swift - unwanted margin in xib

So I have some strange margins to the left and right of my app:

Here is one xib:

enter image description here

And here's another xib from the same app:

enter image description here

And here's the corresponding views from XCode (6.1.1):

enter image description here

and

enter image description here

Does anyone have any thoughts about how I might fix this? I suspect my UINavigationController is misconfigured?

I tried view.layoutMargins = UIEdgeInsetsZero to no avail...

Upvotes: 0

Views: 1135

Answers (2)

oren
oren

Reputation: 3199

There are 3 ways to set constraints without margin:

1) from the pin panel - uncheck the option 'constraint to margin':

enter image description here

2) After you set the constraint, select the constraint and go to the size inspector, uncheck the option 'Relative to margin' :

enter image description here

3) With ctrl drag - press alt (option) to toggle between the options without margin:

enter image description here

Upvotes: 4

Mahesh Agrawal
Mahesh Agrawal

Reputation: 3358

try using this in view did load

self.edgesForExtendedLayout = UIRectEdgeNone;

and in case of auto layout constraint

1) select the view and the main view and give them equal width. 2) make the table view horizontally center in superview. 3) top and bottom whatever you want.

i think this will solve your problem.

Upvotes: 2

Related Questions