动画隐藏tabbar(必须放在对应控制器里)
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:NO];
[self hiddenTabbar];
}
- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self showTabbar];
}
//动画影藏tabbar
-(void)hiddenTabbar{
//增加一个试图即将出现时的方法,并在此设置把tabBar下移,移除整个屏幕,相当于消失了
NSArray *arr1=self.tabBarController.view.subviews;
UITabBar *tabBarView1=[arr1 objectAtIndex:1];
//第一个视图就是全屏,不需要把高度撑满,所以可以不做任何设置
[UIView animateWithDuration:0.5 animations:^{
tabBarView1.frame=CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, 49);
}];
}
//动画展示tabbar
-(void)showTabbar{
//增加一个viewDidAppear,把下移的tabBar再上移,相当于还原到原地
[UIView animateWithDuration:0.5 animations:^{
NSArray *arr2=self.tabBarController.view.subviews;
UITabBar *tabBarView2=[arr2 objectAtIndex:1];
tabBarView2.frame=CGRectMake(0, SCREEN_HEIGHT-49, SCREEN_WIDTH, 49);
}];
}