//导航栏标题颜色/大小
[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16],NSForegroundColorAttributeName:[UIColor whiteColor]}];
//如果想将状态栏变为白色,这样就行
self.navigationController.navigationBar.barStyle = UIStatusBarStyleLightContent;

//使父View的原点坐标包括导航栏的坐标(默认是导航栏下面为原点坐标的)
self.extendedLayoutIncludesOpaqueBars = YES;
- (void)viewWillAppear:(BOOL)animated{//每次出来这个页面时都会运行
self.navigationController.navigationBar.translucent = YES;
//设置导航栏背景图片为一个空的image,这样就透明了
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"空白"] forBarMetrics:UIBarMetricsDefault];

//去掉透明后导航栏下边的一条线
[self.navigationController.navigationBar setShadowImage:[[UIImage imageNamed:@"空白"] init]];

}
- (void)viewWillDisappear:(BOOL)animated{//每次离开这个页面时都会运行
self.navigationController.navigationBar.translucent = NO;//半透明
// 如果不想让其他页面的导航栏变为透明 需要重置
[self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:nil];
}
//导航栏的返回按钮添加图片
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"返回白色描边"] style:UIBarButtonItemStyleDone target:self action:@selector(beackAction)];//记得要添加方法才能执行返回
//导航栏的标题为图片
self.navigationItem.titleView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"logopng@2x"]];
网友评论