在ios开发(http://www.maiziedu.com/course/ios/)中,如何自定义tabbar高度的跳转隐藏问题,比如和系统自带的tabbar高度不一样导致的有一条线的问题,还有push时动画效果等等一些列问题不在这里累述了,当然,思路有很多,可以参考以上链接自己琢磨琢磨,好了,下面直接上个人认为完美解决办法。
// 创建一个自定义的tabbar,并且设置frame(frame写死了,读者可以根据自己的需求改,笔者用的自定义高为44)
ERTabBar *tabBar = [[ERTabBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
CGRect frame = [UIScreen mainScreen].bounds;self.tabBar.frame = CGRectMake(0, CGRectGetHeight(frame)-44, CGRectGetWidth(frame), 44);UIView *transitionView = [[self.view subviews] objectAtIndex:0];
frame.size.height = CGRectGetHeight(frame) - 44;
transitionView.frame = frame;
[self.tabBar addSubview:tabBar];
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// 删除系统自带的tabBarButton
for (UIView *tabBarButton in self.tabBar.subviews) {
if ([tabBarButton isKindOfClass:NSClassFromString(@"UITabBarButton")]) {
[tabBarButton removeFromSuperview];
}
}
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{if (self.childViewControllers.count) { // 不是根控制器
viewController.hidesBottomBarWhenPushed = YES;
[super pushViewController:viewController animated:animated];
}
原文地址:http://11215578.blog.51cto.com/11205578/1761064