Jus*_*anX 3 tabs tabbar uitabbarcontroller ios
我对iOS的UITabBarController标签栏有疑问.
我正在使用a UITabBarController来显示一些视图,但我希望视图能够以尽可能大的屏幕显示.是否可以隐藏标签栏以使其通常不显示,直到用户触摸屏幕,然后标签栏将(带动画)显示在底部.然后,几秒钟后,如果没有任何操作,那么标签栏将再次消失,以便视图再次返回全屏?
这就是你展示它的方式
- (void)showTabBar:(UITabBarController *)tabbarcontroller
{
tabbarcontroller.tabBar.hidden = NO;
[UIView animateWithDuration:kAnimationInterval animations:^{
for (UIView *view in tabbarcontroller.view.subviews) {
if ([view isKindOfClass:[UITabBar class]]) {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y-49.f, view.frame.size.width, view.frame.size.height)];
}
else {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height-49.f)];
}
}
} completion:^(BOOL finished) {
//do smth after animation finishes
}];
}
Run Code Online (Sandbox Code Playgroud)
......这就是你隐藏它的方式
- (void)hideTabBar:(UITabBarController *)tabbarcontroller
{
[UIView animateWithDuration:kAnimationInterval animations:^{
for (UIView *view in tabbarcontroller.view.subviews) {
if ([view isKindOfClass:[UITabBar class]]) {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y+49.f, view.frame.size.width, view.frame.size.height)];
}
else {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height+49.f)];
}
}
} completion:^(BOOL finished) {
//do smth after animation finishes
tabbarcontroller.tabBar.hidden = YES;
}];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9010 次 |
| 最近记录: |