navigationbar颜色和字体颜色的设置

一 navigationbar颜色

不设置为NO会产生色差,但是设置后view会产生偏移,下移64

self.navigationController.navigationBar.translucent = NO;//    Bar的模糊效果,默认为YES
self.navigationController.navigationBar.barTintColor =[UIColor colorWithRed:36/255.0 green:41/255.0 blue:55/255.0 alpha:1];

二 navigationbar字体颜色

1,

NSDictionary *attributes=[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil];
[self.navigationController.navigationBar setTitleTextAttributes:attributes];


2,

UILabel *lb =[[UILabel alloc]initWithFrame:CGRectMake(10, 4, 60, 40)];
lb.text =@"哈哈哈哈";
self.navigationItem.titleView =lb;

这个是全局设置
//设置NavigationBar背景颜色  
[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];  
//@{}代表Dictionary  
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];


你可能感兴趣的:(ios)