Constraint animation not working

Viewed 1024

I'm trying to animate the change of priority in 2 constraints, but I can't seem to make it work. My animation code it's written as the following:

        UIView.animate(withDuration: 0.2, animations: {
        if self.cardHeaderBottomtoBodyTopConstraint.priority == UILayoutPriorityDefaultHigh {
            self.cardHeaderBottomtoBodyTopConstraint.priority = UILayoutPriorityDefaultLow
            self.cardHeaderBottomToBodyBottomConstraint.priority = UILayoutPriorityDefaultHigh
        } else {
            self.cardHeaderBottomtoBodyTopConstraint.priority = UILayoutPriorityDefaultHigh
            self.cardHeaderBottomToBodyBottomConstraint.priority = UILayoutPriorityDefaultLow
        }

        self.flightInformationBodyCard.layoutIfNeeded()
        self.flightInformationBodyCard.updateConstraints()
    }, completion: nil)
1 Answers
Related