iOS导航栏相关属性

 1     //1. 设置navigationBar是否半透明效果,默认是 =YES 的,我们把它变成NO就可以设置navigationBar的颜色为不透明的颜色
 2     self.navigationController.navigationBar.translucent = NO; //不透明
 3     //2. 这个颜色设置默认包含了状态栏
 4     self.navigationController.navigationBar.barTintColor = [UIColor redColor];
 5     
 6     //3. 这个属性设置的是item的渲染色
 7     self.navigationController.navigationBar.tintColor = [UIColor grayColor];
 8     
 9     
10     //4. 设置导航栏title字体颜色
11     //[注意:] 这个设置只能在当前界面生效,如果是在push前设置,则没有效果
12     //另外:push的过去的界面title字体颜色是根据当前界面颜色确定的
13     self.title = @"测试";
14     self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor blueColor]};

 还有就是和跳转相关的属性

HotModel *model = self.dataArr[indexPath.row];
    DetailViewController *detailCon = [[DetailViewController alloc] init];
    detailCon.detailId = model.id;
    //改变跳转后的item属性,比如说title,color之类的
    UIBarButtonItem *item = [[UIBarButtonItem alloc] init];
    self.navigationItem.backBarButtonItem = item;
    //改变item的渲染色
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    //改变DetailCon的返回键item的标题
    item.title = @"Back";
    [self.navigationController pushViewController:detailCon animated:YES];

下面是效果图的对比

                              

 

posted @ 2015-09-10 11:49  Xiao...Xiang  阅读(160)  评论(0)    收藏  举报