object-c 自定义Tabbar

自定义tabbar总会遇到各种问题,例如:

1.push,tabbar不会自动隐藏
2.tabbar背景图片上边缘有条灰色细线 等等

以下内容是创建一个controller继成UITabBarController

 

在viewdidload中,移除  self.tabBar.subviews(请注意这段代码),后自定义一个view进行覆盖,务必注意tabbar系统高度 49 像素,所以如果size不匹配会出现灰色线情况

 

 

在vi_tabbar 上加载各种控件,一般情况加载button,然后点击,根据button的tag值进行subcontroller的切换

    self.selectedIndex   = bu_now.tag;

 

至此,已经完成。

 

扩充:push时默认让tabbar隐藏,ios7以上支持手势滑动返回,如下代码

    self.hidesBottomBarWhenPushed = YES;

    NSMutableDictionary *ndic_current = [[NSMutableDictionary alloc]initWithDictionary:dic_data];

    LB_JECP_CustomJewelry_DetailViewController *detail = [[LB_JECP_CustomJewelry_DetailViewController alloc]init];

    detail.nDic_current = ndic_current;

    detail.detailType = GoodsList;

    [self.navigationController pushViewController:detail animated:YES];

    [detail release];

    self.hidesBottomBarWhenPushed = NO;

  

  if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {

        self.navigationController.interactivePopGestureRecognizer.delegate = nil;

    }

 

posted on 2015-02-03 14:53  马大哈哈  阅读(233)  评论(0)    收藏  举报

导航