iOS Developer

iOS浅谈导航控制器和标签控制器遇到的坑

2016-11-14  本文已影响0人  戴上耳机__世界与我无关
UINavigationController
导航栏样式
 - (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}
 - (UIViewController *)childViewControllerForStatusBarStyle {
    return self.topViewController; // 返回当前的栈顶控制器
}

 - (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleDefault;
}
隐藏导航栏
 - (BOOL)prefersStatusBarHidden {
  return YES;
}
隐藏tabBar
 - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
//tabBar会在创建之前就被隐藏,所以需要判断.
    if (self.childViewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:animated];
}

去掉导航条下面的阴影线
[self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    // 清空阴影图片
    [self.navigationBar setShadowImage:[UIImage new]];
常用的属性
// 设置导航条内容主题色
    self.navigationBar.tintColor = [UIColor whiteColor];
// 设置导航条及状态栏的背景色
    self.navigationBar.barTintColor = [UIColor  blueColor];

//常用的设置导航条标题文字颜色及字体大小的作法
self.navigationBar.titleTextAttributes = @{NSFontAttributeName : [UIFont systemFontOfSize:17], NSForegroundColorAttributeName : [UIColor whiteColor]};

UITabBarController
vc.tabBarItem.selectedImage = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]

或者找到图片这样改


BCFEE316-AF56-4B40-8957-9D8C03676127.png
坑很多,这只是其中几个. 有不足,望指点
上一篇 下一篇

猜你喜欢

热点阅读