Search code examples
iosuiviewuiviewanimationnslayoutconstraint

Animate constraint change not working


I have a view and I want to move it according to its top spacing constraint inside the animation block.

This is the code I use. The constraint is changing, but the frame is still the same; what should I do?

I have an IBOutlet to the constraint named: topConstraint

  [UIView animateWithDuration:0.3f animations:^{
        self.topConstraint.constant -= 80 ;
        [self.view layoutIfNeeded];
    }];

I have read everything about this, but it doesn't seem to work.


Solution

  • have you tried:

     [self.view setNeedsUpdateConstraints];