0

I want to make a UIView animate when it's being closed. I tried reading the following:

http://felipe.sabino.me/ios/2012/05/10/ios-uiview-transition-effects/

iPhone UIView Animation Best Practice

iOS UIView Animation CATransform3DMakeRotation confusion

However, I'd like to make it transition from the side of the screen, as per the image in the Google Chrome app.

Google Chrome UIView disappearing

Is there another animation that is set for this? I was not able to find it... I'm assuming it has to do with animateWithDuration or a CATransform...can somebody point me in the right direction for this?

[EDIT]

I used the below post for an answer as well as this post:

Setting a rotation transformation to a UIView or its layer doesn't seem to work?

I was able to add multiple animations as per below:

[UIView animateWithDuration: .2
                      delay: 0
                    options: (UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction)
                 animations:^{self.view.center = CGPointMake(self.view.frame.origin.x * 3, self.view.frame.origin.y * 2), self.view.transform = CGAffineTransformMakeRotation(M_PI_4/2);}
                 completion:nil];

Previously I was not aware you can add multiple animations so easily. That adds rotation as well as the linear movement together.

Community
  • 1
  • 1
KVISH
  • 12,923
  • 17
  • 86
  • 162

2 Answers2

2

Animate your view so it moves offscreen/shrinks/expands/fades, then do the actual removal when the animation ends.

You can do this by altering the properties of the view (position/size/offset) between a beginAnimations/commitAnimations block. UIKit will then animate these properties over the time specified.

E.g something like;

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.30f];
view.transform = 
  CGAffineTransformMakeTranslation(
    view.frame.origin.x, 
    480.0f + (view.frame.size.height/2)  // move the whole view offscreen
  );
background.alpha = 0; // also fade to transparent
[UIView commitAnimations];

In the animation end notification you can then remove the view.

Vizllx
  • 9,135
  • 1
  • 41
  • 79
0

I've never run Chrome on iOS, so I have to try to guess what your screenshot is showing.

Does the animation go off the screen while shrinking and turning to one side?

And do you mean you want to animate a UIViewController, or a UIView? Are you closing a view controller?

If it's a view controller, how are you managing your view controllers? Are you using a navigation controller, or are you presenting a set of modal view controllers, or some other method?

Duncan C
  • 128,072
  • 22
  • 173
  • 272
  • I just have a basic `UIView`. The animation just slides off of the screen from the bottom right corner. – KVISH Nov 17 '13 at 01:34
  • Is that what your app currently does, or what you want it t od? And what do you mean slides off from the bottom right corner? – Duncan C Nov 17 '13 at 21:20
  • Right now my `UIView` slides down teh bottom of the screen. I want it to rotate a little as in the above screen, and then slide off teh bottom right corner of the screen and disappear – KVISH Nov 17 '13 at 23:33