我想在滚动 Collection View 时隐藏我的标签栏,代码是
#pragma mark - UIScrollViewDelegate
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView
{
[self makeTabBarHidden:YES];
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
[self makeTabBarHidden:NO];
}
- (void)makeTabBarHidden:(BOOL)hide
{
if ( [self.tabBarController.view.subviews count] < 2 )
{
return;
}
UIView *contentView;
UIView *bradeView = [self.tabBarController.view.subviews objectAtIndex:2];
if ( [[self.tabBarController.view.subviews objectAtIndex:0]
isKindOfClass:[UITabBar class]] )
{
contentView = [self.tabBarController.view.subviews objectAtIndex:1];
}
else
{
contentView = [self.tabBarController.view.subviews objectAtIndex:0];
}
// [UIView beginAnimations:@"TabbarHide" context:nil];
if ( hide )
{
contentView.frame = self.tabBarController.view.bounds;
}
else
{
contentView.frame = CGRectMake(self.tabBarController.view.bounds.origin.x,
self.tabBarController.view.bounds.origin.y,
self.tabBarController.view.bounds.size.width,
self.tabBarController.view.bounds.size.height -
self.tabBarController.tabBar.frame.size.height);
}
self.tabBarController.tabBar.hidden = hide;
bradeView.hidden = hide;
}
但在 iOS7 中,当标签栏被隐藏时,有一个黑色的栏不会消失。如何在 iOS7 中隐藏标签栏?
最佳答案
在 Storyboard中,选择要为其隐藏选项卡栏的 View Controller ,转到属性检查器,然后在“ View Controller ”部分 >“扩展边缘”中选择“底部栏”下的复选框。
如果您的栏是不透明的,还请选择 Under Opaque Bars。
关于iOS7无法隐藏tabbar、黑条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20092176/