You can use it to approximate conditional logic.
For example, I had a crop view (imagine a circular cutout for a face profile). If the image was a portrait, I wanted the circle to be closer to the top, but if the image was landscape, there would be no place for it to be off-center, and that would not make sense.
, - ( < =/" >= ). , , , , , , , . , . , AL .
- , , , , , . , , , , , , , . AL , - , , . .
. :
self.addConstraints([
self.leftMarginConstraint,
self.rightMarginConstraint,
self.topMarginConstraint,
self.bottomMarginConstraint,
self.aspectRatioConstraint,
self.constrain(self.maskContainer, self, .CenterX, .Equal),
self.constrain(self.maskContainer, self, .Left, .Equal, priority:900),
self.constrain(self, self.maskContainer, .Right, .Equal, priority:900),
self.constrain(self.maskContainer, self, .Top, .Equal, priority:900),
self.constrain(self, self.maskContainer, .Bottom, .Equal, priority:900),
self.constrain(self.maskContainer, self, .CenterY, .Equal, priority:800, multiplier:0.8),
self.constrain(self.maskContainer, self, .CenterY, .Equal, priority:500),
])