Autolayout: why are these same constrains different?

后端 未结 1 1407
清酒与你
清酒与你 2021-01-27 09:40

I\'m learning autolayout. I\'m currently adding a simple constraint: 0px margin between a view and it superview.

Apparently, there are two ways to add this constraint:

相关标签:
1条回答
  • You've already given the answer. A constraint to the superview is not the same as a constraint to the superview's margin.

    It might be easiest if you think about how you'd form these constraints in code. Here are the attributes you can use:

    https://developer.apple.com/Library/ios/documentation/AppKit/Reference/NSLayoutConstraint_Class/index.html#//apple_ref/c/tdef/NSLayoutAttribute

    As you can see, there is both Right and RightMargin. Pinning a subview's right edge to its superview's Right is not the same as pinning it to its superview's RightMargin.

    0 讨论(0)
提交回复
热议问题