ios开发:navigationBar、 tabBar的设置
2017-07-30 本文已影响3人
SadMine
//导航栏左右按钮图片和文字的颜色(系统自己的图片和文字)
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
//UIBarMetricsDefault 竖屏格式 高度:44
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navigationbar.png"] forBarMetrics:UIBarMetricsDefault];
//UIBarMetricsCompact 横屏样式 高度:32
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"nav-32.png"] forBarMetrics:UIBarMetricsCompact];
//调导航栏标题的的颜色和大小
[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:[UIColor blueColor]}];
//导航页面的跳转
[self.navigationController pushViewController:seven animated:YES];
[self.navigationController popToRootViewControllerAnimated:YES];
//self.navigationController.viewControllers 找到push过去的页面,并放到数组里面
NSArray *viewController = self.navigationController.viewControllers;
[self.navigationController popToViewController:viewController[2] animated:YES];
#pragma mark - 按钮的点击事件
- (void)buttonClick:(UIButton *)button{
//返回任意某一页
//self.navigationController.viewControllers 找到push过去的页面,并放到数组里面
NSArray *viewController = self.navigationController.viewControllers;
[self.navigationController popToViewController:viewController[2] animated:YES];
}
//整体全局更改title的文字和颜色和大小
NSDictionary *dic = @{NSForegroundColorAttributeName : [UIColor redColor], NSFontAttributeName : [UIFont systemFontOfSize:17.0]};
[[UINavigationBar appearance] setTitleTextAttributes:dic];
//设置选项栏项文字选中和不选中的显示状态(颜色或是大小)
[nav1.tabBarItem setTitleTextAttributes:dic forState:UIControlStateNormal];
[nav1.tabBarItem setTitleTextAttributes:selectDic forState:UIControlStateSelected];
//设置选中tabBar选中后图片的颜色额
[self.tabBar setSelectedImageTintColor:[UIColor whiteColor]];
//设置tabBar样式
[self.tabBar setBarStyle:UIBarStyleBlack];
//设置按钮跳转到tabBar的任意一个view
self.tabBarController.selectedViewController = self.tabBarController.viewControllers[1];