Ios navigationBar.barTintColor始终为黑色,无法更改
我的应用程序中的Ios navigationBar.barTintColor始终为黑色,无法更改,ios,iphone,cocoa-touch,Ios,Iphone,Cocoa Touch,我的应用程序中的navigationBar.BartinColor始终为黑色,我无法更改它。我检查了所有类,但我从未将其设置为黑色,但我确实将其设置为UIColor clearColor。尽管如此,酒吧还是黑的。有什么建议吗? 编辑:我发现问题出在我的[UIColor clearColor]上,当我将其更改为任何其他颜色时,它会像应该的那样更改颜色,但clearColor会使其显示为黑色。如果它的IOS7尝试下面的代码 [[UINavigationBar appearance]setBarTin
navigationBar.BartinColor
始终为黑色,我无法更改它。我检查了所有类,但我从未将其设置为黑色,但我确实将其设置为UIColor clearColor
。尽管如此,酒吧还是黑的。有什么建议吗?编辑:
我发现问题出在我的
[UIColor clearColor]
上,当我将其更改为任何其他颜色时,它会像应该的那样更改颜色,但clearColor会使其显示为黑色。如果它的IOS7尝试下面的代码
[[UINavigationBar appearance]setBarTintColor: [<Specify the UIColor you want>];
这将给黑色。如果您想要任何特定的着色颜色,必须在清除后指定
self.navigationController.navigationBar.barTintColor = [UIColor clearColor];
self.navigationController.navigationBar.barTintColor = [UIColor <specify your color>];
self.navigationController.navigationBar.barTintColor=[UIColor clearColor];
self.navigationController.navigationBar.barTintColor=[UIColor];
看看那里
尝试修改导航栏(图像右上角)上的样式
和半透明
属性
如果在修改状态栏颜色时遇到问题,请尝试将其添加到.plist(下面的行)
if([[[UIDevice currentDevice]systemVersion]floatValue]<7.0)
{
[[UINavigationBar外观]setBackgroundImage:[UIImage ImageName:@“nav_bg.png”]forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar外观]setTitleTextAttributes:
@{
UITextAttributeTextColor:[UIColor whiteColor],UITextAttributeTextShadowColor:[UIColor clearColor],UITextAttributeTextShadowOffset:[NSValue valueWithUIOffset:UIOffsetMake(0.0f,1.0f)],UITextAttributeFont:[UIFont fontWithName:@“ArialMT”大小:18.0f]
}];
CGFloat垂直偏移=-4;
[[UINavigationBar外观]setTitleVerticalPositionAdjustment:BarMetrics的垂直偏移量:UIBarMetricsDefault];
}
其他的
{
[[UINavigationBar外观]SetPartIntColor:[UIColor whiteColor]];
//取消注释以更改“后退”按钮的颜色
[[UINavigationBar外观]setTintColor:[UIColor whiteColor]];
//取消注释以指定自定义背景图像
[[UINavigationBar外观]setBackgroundImage:[UIImage ImageName:@“nav_bg_ios7.png”]forBarMetrics:UIBarMetricsDefault];
//取消注释以更改后指示器图像
[[UINavigationBar外观]设置指示符号图像:[UIImage ImageName:@”“];
[[UINavigationBar外观]收件指示符号转换图像:[UIImage ImageName:@”“];
//取消注释以更改标题的字体样式
NSShadow*shadow=[[NSShadow alloc]init];
shadow.shadowColor=[UIColor colorWithRed:0.0绿色:0.0蓝色:0.0 alpha:0.8];
shadow.shadowOffset=CGSizeMake(0,1);
[[UINavigationBar外观]setTitleTextAttributes:[NSDictionary Dictionary With Objects and Keys:[UIColor ColorWith红色:245.0/255.0绿色:245.0/255.0蓝色:245.0/255.0 alpha:1.0],NSForegroundColorAttributeName,shadow,NSShadowAttributeName,[UIFontWithName:@“ArialMT”大小:18.0],NSFontAttributeName,nil];
CGFloat垂直偏移=-4;
[[UINavigationBar外观]setTitleVerticalPositionAdjustment:BarMetrics的垂直偏移量:UIBarMetricsDefault];
}
在iOS 7中尝试:
[self.navigationController.navigationBar setTranslucent:NO];
它不起作用了。。你认为可能是因为我有两个视图在彼此的顶部,所以栏变黑了吗?“我有两个视图在彼此的顶部”。你有自定义的导航栏??我有一个导航控制器,用于我的整个应用程序。在故事板中导航栏是黑色的(就像我发布的图像一样)?如果是这样的话,我很确定在属性检查器中打开
半透明
属性就可以了。或者,着色颜色(在属性检查器中)是黑色的吗?在我的故事板中是clearColor。不,也已检查。请尝试此self.navigationController.navigationBar.barTintColor=[UIColor yourcolor]好的,它确实会将导航栏的颜色更改为白色,但我希望它为“[UIColor clearColor]”,这也不适用于您的代码。[[UINavigationBar外观]setAlpha:0];-(void)viewDidLoad{self.navigationController.navigationBar.alpha=0.0;[super viewDidLoad];}检查第二条注释。,
self.navigationController.navigationBar.barTintColor = [UIColor clearColor];
self.navigationController.navigationBar.barTintColor = [UIColor <specify your color>];
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
// Status bar color
[[UIApplication sharedApplication] setStatusBarStyle:yourStyle];
// Navigation bars color
[UINavigationBar appearance].barStyle = yourStyle;
[UINavigationBar appearance].barTintColor = [UIColor yourColor];
// Navigation bars items color
[UINavigationBar appearance].tintColor = [UIColor yourColor];
if([[[UIDevice currentDevice] systemVersion] floatValue] < 7.0)
{
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"nav_bg.png"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setTitleTextAttributes:
@{
UITextAttributeTextColor: [UIColor whiteColor],UITextAttributeTextShadowColor: [UIColor clearColor],UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0.0f, 1.0f)],UITextAttributeFont: [UIFont fontWithName:@"ArialMT" size:18.0f]
}];
CGFloat verticalOffset = -4;
[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:verticalOffset forBarMetrics:UIBarMetricsDefault];
}
else
{
[[UINavigationBar appearance] setBarTintColor:[UIColor whiteColor]];
// Uncomment to change the color of back button
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
// Uncomment to assign a custom backgroung image
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"nav_bg_ios7.png"] forBarMetrics:UIBarMetricsDefault];
// Uncomment to change the back indicator image
[[UINavigationBar appearance] setBackIndicatorImage:[UIImage imageNamed:@""]];
[[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:[UIImage imageNamed:@""]];
// Uncomment to change the font style of the title
NSShadow *shadow = [[NSShadow alloc] init];
shadow.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8];
shadow.shadowOffset = CGSizeMake(0, 1);
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], NSForegroundColorAttributeName,shadow, NSShadowAttributeName,[UIFont fontWithName:@"ArialMT" size:18.0], NSFontAttributeName, nil]];
CGFloat verticalOffset = -4;
[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:verticalOffset forBarMetrics:UIBarMetricsDefault];
}
[self.navigationController.navigationBar setTranslucent:NO];