我正在开发iOS 7应用程序。我的导航栏过去如下图所示:

但是在添加了这段代码之后
self.edgesForExtendedLayout = UIRectEdgeNone;导航车的颜色变深了,如下图所示:。

我们如何让导航栏像第一张图片一样明亮,同时保持上面的代码?
发布于 2014-02-07 19:56:00
默认情况下,导航栏的“半透明”属性设置为“YES”。
此外,还有一个系统模糊应用于所有导航栏。在这种设置下,iOS 7倾向于降低条形图的颜色饱和度。
差半透明设置

设置色调颜色

关闭半透明设置

将此代码放入didFinishLaunchingWithOptions:的appDelegate.m中
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
if (floor(NSFoundationVersionNumber) >= NSFoundationVersionNumber_iOS_6_1)
{
// Load resources for iOS 7 or later
// To change the background color of navigation bar
[[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0x067AB5)];
// To change the color of back button
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
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:@"HelveticaNeue-CondensedBlack" size:21.0], NSFontAttributeName, nil]];
}发布于 2014-02-07 15:34:46
试试这个
对于iOS7,导航栏的颜色可以通过以下几行进行更改。
if(IS_IOS7){
//Your color code
self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:34.0/255.0 green:59.0/255.0 blue:135.0/255.0 alpha:1.0];
self.navigationController.navigationBar.translucent = NO;
self.navigationController.navigationBar.titleTextAttributes
= @{UITextAttributeTextColor : [UIColor whiteColor]};
[self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
}发布于 2014-02-07 15:49:34
在iOS 7中,导航栏的tintColor会影响背面指示器图像、按钮标题和按钮图像的颜色。barTintColor属性影响条形图本身的颜色。此外,默认情况下导航栏是半透明的。关闭或打开半透明不会影响按钮,因为它们没有背景。
将此代码添加到您的appdelegate中
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)
{
[[UINavigationBar appearance] setBarTintColor:[UIColor yourColorCode]];
//optional
NSShadow *shadowObj = [[NSShadow alloc] init];
shadowObj.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8];
shadowObj.shadowOffset = CGSizeMake(0, 1);
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:205.0/255.0 green:255.0/255.0 blue:45.0/255.0 alpha:1.0], NSForegroundColorAttributeName,
shadowObj, NSShadowAttributeName,
[UIFont fontWithName:@"Arial" size:18.0], NSFontAttributeName, nil]];
[[UINavigationBar appearance] setTintColor:[UIColor blackColor]];
}https://stackoverflow.com/questions/21621750
复制相似问题