[英]How to add UIViewController as subview , to be visible above tabbar?
我想將UIViewController的視圖添加為子視圖。 但是self.view有一個UITabBarController。 我想在標簽欄上方顯示子視圖。 這樣該標簽欄就隱藏在子視圖的后面。 請提出一些想法。
如果要隱藏/顯示視圖的UITabBarController,請嘗試以下操作:
隱藏標簽欄:
- (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)];
}
}
}
可能會有所幫助。
在您分配和初始化TabBar的位置,編寫此行
objectOfTabbar.hidden=YES;
然后將子視圖的框架與TabBarController
相同。 這樣,您的標簽欄將被隱藏並顯示視圖。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.