translatesAutoresizingMaskIntoConstraints
A Boolean value that determines whether the view’s autoresizing mask converts to Auto Layout constraints.
Declaration
var translatesAutoresizingMaskIntoConstraints: Bool { get set }Discussion
If this property’s value is true, the system creates a set of constraints that duplicate the behavior specified by the view’s autoresizing mask. You can also modify the view’s size and location using the view’s frame, bounds, or center properties, creating a static, frame-based layout within Auto Layout.
Because the autoresizing mask constraints specify the view’s size and position, you can’t add constraints to modify this size or position without introducing conflicts. To use Auto Layout to dynamically calculate the size and position of your view, set this property to false, and then provide a nonambiguous, nonconflicting set of constraints for the view.
Set this property on a subview from a containing superview or view controller, not from within the view itself:
customSubview.translatesAutoresizingMaskIntoConstraints = falseDon’t set this property on self inside a custom view’s own code, because this prevents the containing superview from managing its layout. Don’t modify this property’s value for views that UIKit classes manage, such as UITableViewCell, arrangedSubviews, and view. These classes handle layout automatically, and changing this property interferes with their layout behavior.
By default, the system sets this property to true for any view you programmatically create. If you add views in Interface Builder, the system automatically sets this property to false.