hiding TabBar when rotating iPhone device to landscape

前端 未结 8 1600
旧时难觅i
旧时难觅i 2020-12-09 12:21

So here is what i have: A UITabBarController that handles different UIViewControllers. In one of the UIViewController i am trying to switch the view being displayed when the

8条回答
  •  旧巷少年郎
    2020-12-09 12:37

    Maybe you want to use this

    - (void)willAnimateRotationToInterfaceOrientation:UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
    {
        [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
    
        __block UIView *weakTabBar = [self.tabBarController.view.subviews objectAtIndex:1];
        weakTabBar.alpha = 0;
        [UIView animateWithDuration:duration
                              delay:0
                            options:UIViewAnimationOptionCurveEaseIn // slow at the beggining
                         animations:^{
                             weakTabBar.alpha = 1;
                         }
                         completion:^(BOOL finished) {
                             weakTabBar.alpha = 1;
                         }];
        }
    

    }

    This doesn't hide the tab bar but makes the rotate animation smoother.

提交回复
热议问题