4

I use storyboard and autolayout.

I place a thin UIView inside a UIViewController's UIView (which gets pushed to a UINavigationController). Then I add constraint to make the thin UIView resize itself to keep x-margin = 0 and x-ending-margin = 0. (left edge to right edge)

I see that it recommends the value for the constraint as -20 and also -20 for the trailing space. If I set it to 0, I see whitespace before and after my UIView. Why? What is that -20?

When I test it on a small device like iPhone 5, I see that -20 becomes more like -30 or something..

Why does that happen? Is there a way to somehow fix it so I can safely use 0 as the constraint for every situation?

3
  • 2
    Is the 'constrain to margins' checkbox ticked? Commented Sep 1, 2015 at 7:02
  • @Wain Yes. When I uncheck it, it works. What does that really mean? Commented Sep 1, 2015 at 7:03
  • 2
    you can check this...stackoverflow.com/questions/25807545/… Commented Sep 1, 2015 at 7:49

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.