iOS 删除系统自带的tabbar
一、删除系统自带的tabbar
在开发中,我们时常会需要自己定义tabbar,使用自定义tabbar时,返回或者跳转时会遇到tabbar重影的现象,这个时候我们需要将系统的tabbar
// 实现navigationController的代理方法
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{// 删除系统自带的tabBarButtonfor (UIView *tabBar in self.tabBarController.tabBar.subviews) {if ([tabBar isKindOfClass:NSClassFromString(@"UITabBarButton")]) {[tabBar removeFromSuperview];}}
}
二、设置自定义tabbar的选中效果
MainTabBarViewController * tabBarController = (MainTabBarViewController *)self.navigationController.tabBarController;tabBarController.selectedIndex = 0;tabBarController.customTabBar.selectedButton.selected = NO;for (UIView *child in tabBarController.customTabBar.subviews) {if ([child isKindOfClass:[MainTabBarButton class]]) {if (child.tag == 0) {tabBarController.customTabBar.selectedButton = (MainTabBarButton *)child;tabBarController.customTabBar.selectedButton.selected = YES;}}}
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
