1

I have a view that has a small popover mode placed at the bottom of the screen, and a full screen mode. When animating between the two, the size is changing immediately at the start of the animation.

For example, when changing from full screen to small mode, the footer of my view starts at the bottom, snaps up near the top, and then the whole (now shrunken) view animates down to where it belongs.

Instead, I want my footer to stay in (approximately) the same place. The bottom of the view should only move by a few pixels, and the top should do most of the moving.

I have tried setting both the frame, and the center/bounds but they both have the same effect. How can I animate this smoothly?

Below, method A and method B both result in the same, ugly animation regardless of direction (large->small/small->large).

CGRect bounds = newFrame;
bounds.origin = CGPointZero;
CGPoint center = CGRectGetCenter(newFrame);
[UIView animateWithDuration:0.75
                      delay:0.0
     usingSpringWithDamping:0.7
      initialSpringVelocity:0.0
                    options:UIViewAnimationOptionCurveEaseIn | UIViewAnimationOptionAllowUserInteraction
                 animations:^{
                     // Method A
                     view.frame = newFrame;
                     // Method B
                     view.center = center;
                     view.bounds = bounds;
                 }
                 completion:completion];
arsenius
  • 12,090
  • 7
  • 58
  • 76
  • 1
    Did a simple test with your animation values. Works for me. Do you have any auto layout constraints set on the view? – Chris Slowik Feb 26 '16 at 14:55
  • 1
    I have constraints set on the subview. I ended up using the solution here: http://stackoverflow.com/a/13150175/467209. Just adding ```[view layoutSubviews]``` fixes the problem. – arsenius Feb 29 '16 at 00:18
  • Aha yea thats because the constraints need to do their thing first. – Chris Slowik Mar 01 '16 at 00:54

0 Answers0