use*_*789 37 xcode objective-c ios swift
我正在使用此代码隐藏TabBar:
self.tabBarController.tabBar.hidden=YES;
Run Code Online (Sandbox Code Playgroud)
我在我的项目中隐藏了tabBarController.但它在Ios7的视图底部显示了黑条.当我回到相同的视图时它看起来很好.任何帮助将不胜感激.
CTi*_*PKA 52
注意:它仅适用于iOS6和7.
在iOS 7中,为了扩展可点击区域并在隐藏的UITabBar上隐藏黑条,你应该为你的UIViewController启用'Extend Edges - Under Opaque Bars'选项.

或者您可以以编程方式设置此属性:
[self setExtendedLayoutIncludesOpaqueBars:YES]
以下是隐藏或移动TabBar for iOS 6/7的代码示例:
UITabBarController *bar = [self tabBarController];
if ([self respondsToSelector:@selector(setExtendedLayoutIncludesOpaqueBars:)]) {
//iOS 7 - hide by property
NSLog(@"iOS 7");
[self setExtendedLayoutIncludesOpaqueBars:YES];
bar.tabBar.hidden = YES;
} else {
//iOS 6 - move TabBar off screen
NSLog(@"iOS 6");
CGRect screenRect = [[UIScreen mainScreen] bounds];
float height = screenRect.size.height;
[self moveTabBarToPosition:height];
}
//Moving the tab bar and its subviews offscreen so that top is at position y
-(void)moveTabBarToPosition:(int)y {
self.tabBarController.tabBar.frame = CGRectMake(self.tabBarController.tabBar.frame.origin.x, y, self.tabBarController.tabBar.frame.size.width, self.tabBarController.tabBar.frame.size.height);
for(UIView *view in self.tabBarController.view.subviews) {
if ([view isKindOfClass:[UITabBar class]]) {
[view setFrame:CGRectMake(view.frame.origin.x, y, view.frame.size.width, view.frame.size.height)];
} else {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, y)];
view.backgroundColor = [UIColor blackColor];
}
}
}
Run Code Online (Sandbox Code Playgroud)
从这篇文章中获取移动Tab Bar的功能.
PSs*_*sam 20
下一个代码适合我
- (void)showTabBar {
[self.tabBar setTranslucent:NO];
[self.tabBar setHidden:NO];
}
- (void)hideTabBar {
[self.tabBar setTranslucent:YES];
[self.tabBar setHidden:YES];
}
Run Code Online (Sandbox Code Playgroud)
Tea*_*Tea 13
试试这个:
- (BOOL)hidesBottomBarWhenPushed {
return YES;
}
Run Code Online (Sandbox Code Playgroud)
To showTabbar:
- (void)showTabBar:(UITabBarController *) tabbarcontroller
{
//[UIView beginAnimations:nil context:NULL];
//[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 521, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 521)];
}
}
// [UIView commitAnimations];
}
To hide Tabbar:
- (void)hideTabBar:(UITabBarController *) tabbarcontroller
{
//[UIView beginAnimations:nil context:NULL];
//[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 568, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 568)];
}
}
//[UIView commitAnimations];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20477 次 |
| 最近记录: |