Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CGAffineTransformMakeScale animation not working

I have a viewcontroller with a view that I am dismissing using a UIView animation to scale it down to 0 before removing it. My code for dismissing it is:

[UIView animateWithDuration:_dismissAnimationDuration
                      delay:0.0
                    options:UIViewAnimationOptionCurveEaseIn
                 animations:^(void) {
                     _menuContainerView.transform = CGAffineTransformMakeScale(0.0, 0.0);
                 }
                 completion:^(BOOL finished){
                     if ([_delegate respondsToSelector:@selector(popUpMenuDidClose)])
                     {
                         [_delegate popUpMenuDidClose];
                     }

                     [self.view removeFromSuperview];
                     [self removeFromParentViewController];
                 }];

That works perfectly when building from XCode 5 onto devices running both iOS 7 and iOS 8. But, as soon as I build to iOS 8 from XCode 6 (beta 6 and beta 7) the view just cuts away instead of animating. If that wasn't weird enough as soon as I change the target scale to (0.001, 0.001) it animates fine regardless of XCode version. Any ideas as to why I can't animate to an actual (0.0, 0.0) scale with XCode 6?

like image 477
sfeuerstein Avatar asked Sep 03 '14 20:09

sfeuerstein


2 Answers

So after speaking with a developer at Apple the reasoning I got back was that some base frameworks need to work with the inverses of transform matrices quite often, and since there is no inverse for the zero matrix the animation just returns out to avoid crashing. Hopefully this post has helped others who ran into a similar situation.

like image 160
sfeuerstein Avatar answered Nov 19 '22 06:11

sfeuerstein


If acceptable for you, set the scale values to 0.01 like so:

_menuContainerView.transform = CGAffineTransformMakeScale(0.01, 0.01);

Reference

like image 6
abc123 Avatar answered Nov 19 '22 08:11

abc123