如何将UIViewController添加为subview,使其在标签栏上方可见? [英] How to add UIViewController as subview , to be visible above tabbar?
本文介绍了如何将UIViewController添加为subview,使其在标签栏上方可见?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将UIViewController的视图添加为子视图.但是self.view有一个UITabBarController.我想在标签栏上方显示子视图.这样该标签栏就隐藏在子视图的后面.请提出一些想法.
I want to add the view of a UIViewController as a subview. But self.view is having a UITabBarController. I want to display the subview above tabbar. So that tab bar hides behind subview. Please suggest some idea.
推荐答案
如果要隐藏/显示视图的UITabBarController,请尝试以下操作:
Try this, if you want to hide/show the UITabBarController of view:
要隐藏标签栏:
- (void)hideTabBar:(UITabBarController *) tabbarcontroller
{
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, (isiPhone5?568:480), view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, isiPhone5?568: 480)];
}
}
}
用于显示标签栏:
- (void)showTabBar:(UITabBarController *) tabbarcontroller
{
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, (isiPhone5?519:431), view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, isiPhone5?519:431)];
}
}
}
可能会有所帮助.
这篇关于如何将UIViewController添加为subview,使其在标签栏上方可见?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文