美文网首页
TabBarItem&UINavigationItem&

TabBarItem&UINavigationItem&

作者: SuAdrenine | 来源:发表于2017-11-23 14:07 被阅读14次
    tabBarItem:设置tabBar上按钮的内容(tabBarButton)
    uinavigationItem:设置导航条上的内容(左边,右边,中间)
    uiBarButtonItem:导航条上具体的内容,如leftBarButtonItem
    

    设置两个NavigationItem在同一边

    UIBarButtonItem *oneItem;
    UIBarButtonItem *twoItem;
    self.navigationItem.rightBarButtonItems = @[oneItem,twoItem];
    

    底部tabBar在页面跳转时隐藏
    vc.hidesBottomBarWhenPushed = YES;//必须是在VC跳转之前设置才有效果

    返回按钮样式
    1、在页面上设置,谁的页面谁设置

    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setTiele:@"返回" forState:UIControlStateNormal];
    [btn setImage:image forState:UIControlStateNormal];
    [btn setImage:image forState:UIControlStateHighlighted];
    [btn addTarget:target action:action forControlEvents:controlEvents];
    [btn sizeToFit];
    btn.contentEdgeInsets;//设置内边距
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:containView];
    

    2、自定义UINavigationController 的pushViewController方法

    -(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    if(self.childViewControllers.count>0){  //非空控制器,0是因为还未push进去,[super push...]调用之后才有 ,重写这个方法会导致向右侧滑返回上一页的手势失效(1、手势失效,2、代理的缘故,清空代理self.navigationController.interactivePopGestureRecognizer.delegate = nil;
    但是要判定是不是根控制器,所以自己遵守这个代理,同时设置方法,gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch,返回NO则是不响应侧滑事件)
            viewController.navigationItem.leftBarButtonItem = 自定义(leftBarButtonItem改成backBarButtonItem可以修复)
        }
        [super pushViewController:(UIViewController *)viewController animated:(BOOL)animated];
    }
    

    3、视图控制器跳转卡顿
    解决办法:给视图控制器设置背景颜色

    相关文章

      网友评论

          本文标题:TabBarItem&UINavigationItem&

          本文链接:https://www.haomeiwen.com/subject/wxnsattx.html