How would I convert this into a constraint?
"V:|->=0-[contentView]->=0-|"
Would it look like this?
contentView.topAnchor.constraint(lessThanOrEqualTo: topAnchor, constant: 0.0)
contentView.bottomAnchor.constraint(lessThanOrEqualTo: bottomAnchor, constant: 0.0)
Since you haven't specified which view is the
superviewofcontentView, we'll have to usecontentView.superview!for the containing view. Therefore, your visual format is equivalent to:Notes:
contentViewhas already been added as a subview of another view (which you should always do before creating constraints), then force unwrappingcontentView.superviewis safe.contentViewwill start lower on the screen than itssuperviewand the coordinates grow in the downward direction, so its offset will be larger making the constraintgreaterThanOrEqualTothe superview'stopAnchor.contentViewwill end above or touching its superview'sbottomAnchor, so theconstantin this case will belessThanOrEqualTo0.