Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

16 pixels margin left and right on UIView created with autolayout

I use autolayouts not for a long time and they often confuse me.

I have a wired constraints behaviour. I want to create a red view and make its margins 1/1/1/1. I tap a corresponded icon in the storyboard and set all fourth constraints to 1.

enter image description here

First of all values for left and right constraints are -16 and it's very strange. I have no idea where Xcode takes them.

I set all constraints to 1 and run my application. On the screen I see the view with top and bottom margins equal to 1 and right and left equal to 15.

And I have this behaviour always in every project. It very confuses me and don't give make UI correctly.

Does anybody know how can I avoid it? Everything I need it's say "Hey, Xcode, set margins for this view to 1/1/1/1" and the visible result will be the view with margins 1/1/1/1.

enter image description here

like image 576
Rostyslav Druzhchenko Avatar asked Oct 27 '14 14:10

Rostyslav Druzhchenko


1 Answers

As usual, just after posing a question I've found a solution. When you set constrains turn the "Constrain to margins" checkbox off.

enter image description here

like image 98
Rostyslav Druzhchenko Avatar answered Oct 31 '22 13:10

Rostyslav Druzhchenko