0

I want to change to another tab but i also want to open it from bottom. Like a vertical transition.

I was trying to do like this :

  -(void)test{

    UIView * toView = [[self.tabBarController.viewControllers objectAtIndex:1] view];


    UIImage *img=[self imageWithView:toView];



    [UIView transitionWithView:img
                      duration:1.0f
                       options:UIViewAnimationOptionCurveEaseIn
                    animations:^{
                        self.tabBarController.selectedIndex = 0;
                    } completion:NULL];



}

- (BOOL)tabBarController:(UITabBarController *)tabBarController
shouldSelectViewController:(UIViewController *)viewController{
    return false;
}
- (UIImage *) imageWithView:(UIView *)view
{
    UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);
    [view.layer renderInContext:UIGraphicsGetCurrentContext()];

    UIImage * img = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();







    return img;
}

but it's not the effect that i want . Any ideea?

Adina Marin
  • 663
  • 1
  • 4
  • 15

1 Answers1

0

This is my solution:

Firstly. return false in the UITabBarController' delegate. So the system won't change the tab immediately when user selecting the tab.
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController

Secondly. Capture your toView to an image

Thirdly. Do any animation you want with the imageView.

Finally. Set selectedIndex of your tabBarController and remove the imageView when the animation completed.

Feel free to ask me. Thanks!

Community
  • 1
  • 1
hzwzw
  • 1,042
  • 12
  • 17
  • @AdinaMarin Add the image to UIWindow with a origin frame(maybe outside of the screen). then do the animation that moving the image to the view frame. – hzwzw Oct 12 '15 at 16:24