navigationbar颜色和字体颜色的设置

来源:互联网 发布:lovely cation2 知乎 编辑:程序博客网 时间:2024/04/24 02:04

一 navigationbar颜色

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

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

二 navigationbar字体颜色

1,

<span style="font-size:10px;">NSDictionary *attributes=[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil];[self.navigationController.navigationBar setTitleTextAttributes:attributes];</span>


2,

<span style="font-size:10px;">UILabel *lb =[[UILabel alloc]initWithFrame:CGRectMake(10, 4, 60, 40)];lb.text =@"哈哈哈哈";self.navigationItem.titleView =lb;</span>

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


0 0
原创粉丝点击