When should translatesAutoresizingMaskIntoConstraints be set to true?

后端 未结 3 555
情书的邮戳
情书的邮戳 2020-12-04 11:03

I\'ve read the documentation. But I\'m still not sure when I need to not set it to false. In the code below if I set it to false I won\'t see the h

3条回答
  •  情书的邮戳
    2020-12-04 11:40

    • For programmatically created view default is true and for views from Interface Builder default is false

      If the property is (or set to) True, the system automatically creates a set of constraints based on the view’s frame and its autoresizing mask. And if you add your own constraints, they inevitably conflict with the autogenerated constraints. This creates an unsatisfiable layout. So When programmatically instantiating views, be sure to set their translatesAutoresizingMaskIntoConstraints property to NO.

提交回复
热议问题