From this stack example i figured out how to animate the constant parameter of a named constraint. It works fine, but I've encountered a problem I haven't found a solution to. I have the UIViewAnimationOptionBeginFromCurrentState option set for the animation and via an IBAction method want to be able to switch animations final state, even during the animation. Here is the code:
- (IBAction)animate:(id)sender {
self.brownViewHeightConstraint.constant = self.expanded ? 100.f : 390.f;
[self.brownView setNeedsUpdateConstraints];
self.expanded = !self.expanded;
[UIView animateWithDuration: 1.0
delay: 0
options: UIViewAnimationOptionBeginFromCurrentState
animations: ^{
[self.brownView layoutIfNeeded];
}
completion:^(BOOL finished) {
}
];
}
The animation doesn't honor the UIViewAnimationOptionBeginFromCurrentState option. How would I accomplish this behavior using AutoLayout?