展开全部
修改 TabBar 的 subview 的 frame 就可以了。其中,TabBar 的subview 共有两个,一个叫UITabBar,另一个叫UITranstionview。将UITabBar的 y 向下移62616964757a686964616fe58685e5aeb93133336130633949个单位,把UITranstionview 的 hight 加长 49 个单位。但是有时候这样隐藏tabbar后,原来的viewcontroller上的view就会被拉长。解决方法是修改viewcontroller上的view 的autosizing。
以下是具体代码,另加上了动画效果:for (UIView *v in [self.tabBarController.view subviews]) {
if ([v isKindOfClass:[UITabBar class]]) {
[UIView animateWithDuration:kDuration delay:0.0f options:UIViewAnimationOptionCurveEaseOut animations:^(){
CGRect frame = v.frame;
frame.origin.y += 49.0f;
v.frame = frame;
} completion:^(BOOL complete)
{
isAnimating = NO;
}];
} else {
isAnimating = YES;
[UIView animateWithDuration:kDuration delay:0.0f options:UIViewAnimationOptionCurveEaseOut animations:^(){
CGRect frame = v.frame;
frame.size.height += 49.0f;
v.frame = frame;
} completion:nil];
}
}