iOS开发设置导航栏的背景颜色、标题颜色、字体、大小
2017-08-22 本文已影响111人
lczalh
//设置导航栏的背景颜色

UINavigationBar *bar = [UINavigationBar appearance];
bar.barTintColor = [UIColor colorWithRed:62/255.0 green:173/255.0 blue:176/255.0 alpha:1.0];
//设置导航栏title字体类型和大小
[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"Helvetica-Bold" size:22],NSForegroundColorAttributeName:[UIColor whiteColor],}];
设置导航条背景图片时有时self.view会向下偏移64像素
//此句代码解决坐标问题
[self.navigationController.navigationBar setTranslucent:YES];
//当translucent = YES,controller中self.view的原点是从导航栏左上角开始计算
//当translucent = NO,controller中self.view的原点是从导航栏左下角开始计算