Ios 导航栏背景色-半透明性为否
我想将导航栏的背景色更改为纯绿色 规则:我不能搞乱AppDelegate:) 我试过:Ios 导航栏背景色-半透明性为否,ios,objective-c,uinavigationcontroller,uinavigationbar,Ios,Objective C,Uinavigationcontroller,Uinavigationbar,我想将导航栏的背景色更改为纯绿色 规则:我不能搞乱AppDelegate:) 我试过: //It's green but it's translucent [self.navigationController.navigationBar setBackgroundColor:[UIColor colorWithRed:77/255.0 green:255/255.0 blue:100/255.0 alpha:1.0f]]; //It's white, first line has no ef
//It's green but it's translucent
[self.navigationController.navigationBar setBackgroundColor:[UIColor colorWithRed:77/255.0 green:255/255.0 blue:100/255.0 alpha:1.0f]];
//It's white, first line has no effect
[self.navigationController.navigationBar setBackgroundColor:[UIColor colorWithRed:77/255.0 green:255/255.0 blue:100/255.0 alpha:1.0f]];
[self.navigationController.navigationBar setTranslucent:NO];
//Same result as case 1
[self.navigationController.navigationBar setAlpha:0.0f];
[self.navigationController.navigationBar setBackgroundColor:[UIColor colorWithRed:77/255.0 green:255/255.0 blue:100/255.0 alpha:1.0f]];
//Too dark
[self.navigationController.navigationBar setBarStyle:UIBarStyleBlackTranslucent];
[self.navigationController.navigationBar setBackgroundColor:[UIColor colorWithRed:77/255.0 green:255/255.0 blue:100/255.0 alpha:1.0f]];
//Only affects the back button's color:
[self.navigationController.navigationBar setTintColor:[UIColor greenColor]];
有什么想法吗
谢谢,我没看到还有barTintColor和TintColor。接受最早的答案。请使用以下代码,这可能会对您有所帮助
navController.navigationBar.barTintColor = [UIColor yourcolor];
在viewController didLoad方法中使用这行代码
self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:29.0f/255.0f green:149.0f/255.0f blue:174.0f/255.0f alpha:1.0f]
用这个,
self.navigationController.navigationBar.tintColor=[UIColor colorWithRed:19.0/255.0f green:52.0/255.0f blue:36.0/255.0f alpha:1];
使用navigationBar的barTintColor属性您是否使用了情节提要?然后选择viewcontroller,并在inspector中的“模拟度量”下将顶部栏设置为不透明导航栏