How to make leading and trailing Constraint equal

I want to make two constraints equal http://prntscr.com/ldipc3 is ti possible and how ??

Replies

This is not a question about a feature of the Swift language, so it’s posted in the wrong forum. Cocoa Touch might be better.


I would use spacer views. Where you have your leading and trailing constraints now, add empty UIViews instead, with fixed height and zero leading and trailing space. Then give the two views an equal width constraint.

You can also do it programmatically, creating IBOutlets for the constraints and setting the .constant property in code. You will have to calculate tyhe value so that the constraint can be satisfied


How are those 2 constraints defined now ?

I want to add it without taking background uiview is it possible?

Have you considered doing it in code ?

I’m not sure what you’re asking. The spacer views would have isOpaque unchecked, background colour = clear. They are invisible.

Doing it in code is unnecessary unless you want to do it just as a learning exercise. It’s pretty trivial to let auto layout handle it, either with spacer views as I first suggested, or with a parent enclosing view that takes up the whole space then the other view centred in that.