[英]Hide tab for current view controller in tab bar controller
我只是想知道如何隐藏当前视图控制器的Tab Bar Controller
中的Tab Bar Controller
卡项
从controllersArray ex中删除预期的索引。 (1)
NSMutableArray *controllersArray = [NSMutableArray arrayWithArray:self.tabBar.viewControllers];
[controllersArray removeObjectAtIndex: 1];
[self.tabBar setViewControllers:controllers animated:YES];
检查此答案,我也从您的问题隐藏标签栏项目并对齐其他标签项目中发现了类似的问题,希望对您有所帮助。
首先,我认为无法隐藏UITabBarItem
它继承自UIBarItem
但没有hidden
属性-UIBarItem文档
您可以尝试将标签栏的selectedViewController
属性与当前视图控制器进行比较吗? -以下内容可能会起作用。
if (self.tabBarController.selectedViewController == self) {
// Do Stuff
}
但是即使那样,我认为您仍然很难隐藏选项卡栏项本身。
UIView *parent = self.tabBarController.tabBar.superview; // UILayoutContainerView
UIView *content = [parent.subviews objectAtIndex:0]; // UITransitionView
UIView *window = parent.superview;
[UIView animateWithDuration:0.2
animations:^{
CGRect tabFrame = self.tabBarController.tabBar.frame;
tabFrame.origin.y = CGRectGetMaxY(window.bounds);
self.tabBarController.tabBar.frame = tabFrame;
content.frame = window.bounds;
}];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.