Vlad Vlad - 7 days ago 4
iOS Question

What happens when attaching exactly the same NSLayoutConstraints to the same UIView multiple times?

The question says it all. Does it get ignored? Or does it just keep attaching the same constraint multiple times?

Also is there any performance issue if I do this?

I'm asking because the alternative seems to be keep reference to all constraints as they get attached and then later look them up to make this decision. It would be nice if I don't have to implement all this logic.

Answer

Yes, adding same(same NSLayoutConstraint object) constraints again, are ignored.

enter image description here

Comments