7

All I can seem to find in examples are using transforms or are modifying frames. Have I missed something obvious? Currently the other animations (fades) are all working fine, however the constraint stays locked in position.

A quick code snippet:

[[customViewController view] layoutIfNeeded];
[UIView animateWithDuration:2 animations:^{

    [[customViewController constraintToAnimate] setConstant:1024];
    [[customViewController view] layoutIfNeeded];

} completion:^(BOOL finished) {
    [transitionContext completeTransition:YES];
}];
SeanCAtkinson
  • 753
  • 1
  • 4
  • 15
  • Guess I should take that as a no.. – SeanCAtkinson Mar 22 '14 at 10:53
  • I have exactly the same question. Any help or discovery? – Ricardo Mar 26 '14 at 11:23
  • 1
    I haven't found a way yet - I'm falling back to frame animation for now – SeanCAtkinson Mar 26 '14 at 15:05
  • Thanks for reply. But I want to use autolayout in my UI. Can I mix autolayout and at the same time use frames in transitions? Thanks. – Ricardo Mar 27 '14 at 10:22
  • 1
    Yes frames work fine in the transitions - though you do have a lot more code to write. – SeanCAtkinson Mar 27 '14 at 14:37
  • No, you should not be updating frames manually if you are using auto layout, since the layout engine will change the frames out from under you to satisfy the constraints. – Zev Eisenberg May 15 '14 at 19:25
  • Not during a custom transition. In normal code you're absolutely right and shouldn't touch the frames when using autolayout, however, in this case autolayout isn't working in a custom transition. Unless you can help us all out and provide some sample that proves otherwise? – SeanCAtkinson May 15 '14 at 20:23
  • Are you sure the value of the constant is different than 1024 before the animation block is executed ? – Petar Sep 08 '14 at 22:18

1 Answers1

0

You need to call layoutIfNeeded on the [[customViewController view] superview]

ZigDanis
  • 154
  • 1
  • 11
  • Not sure if this was the answer back in the day but it was the most helpful. Testing in iOS 9 seems to just allow constraint manipulation directly without having to worry about the superview. – SeanCAtkinson May 27 '16 at 18:22