ios - UINavigationBar 变黑

标签 ios iphone uinavigationcontroller uinavigationbar

首先,当我调用 presentViewController:navigationController 时,它会显示正常的绿色导航栏。但是在动画完成后导航栏变得有点暗。

if(!userPageViewController)
    userPageViewController = [[UserPageViewController alloc]initWithUser:tempUser];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:userPageViewController];
[self presentViewController:navigationController animated:YES completion:nil];

当我按下主页按钮时,导航栏像这张图片一样变成黑色。 https://dl.dropboxusercontent.com/u/14066789/2013-12-04%2012.27.45.png

xib 文件中的顶部栏设置为半透明导航栏 为什么会变黑?

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title = @"Личный кабинет";
    [myTableView setBackgroundColor:[UIColor clearColor]];

    UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithTitle:@"Закрыть" style:UIBarButtonItemStyleBordered target:self action:@selector(backPressed:)];
    self.navigationItem.leftBarButtonItem = btn;
    self.navigationItem.backBarButtonItem  = nil;

    UIBarButtonItem *exitBtn = [[UIBarButtonItem alloc] initWithTitle:@"Выход" style:UIBarButtonItemStyleBordered target:self action:@selector(logOut:)];
    self.navigationItem.rightBarButtonItem = exitBtn;
    scroll.contentSize = CGSizeMake(320.0f, 400.0f);

    if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
        self.edgesForExtendedLayout = UIRectEdgeNone;

}

-(void)viewWillAppear:(BOOL)animated
{
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)
    {
        UIColor * barColor = [UIColor
                              colorWithRed:222.0/255.0
                              green:255.0/255.0
                              blue:229.0/255.0
                              alpha:1.0];
        [self.navigationController.navigationBar setBarTintColor:barColor];
        UIColor * barTintColor = [UIColor
                                  colorWithRed:48.0/255.0
                                  green:140.0/255.0
                                  blue:76.0/255.0
                                  alpha:1.0];
        [self.navigationController.navigationBar setTintColor:barTintColor];

        NSDictionary *navbarTitleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
                                                   barTintColor,UITextAttributeTextColor,
                                                   [UIColor clearColor], UITextAttributeTextShadowColor,
                                                   [NSValue valueWithUIOffset:UIOffsetMake(0, 0)], UITextAttributeTextShadowOffset, nil];

        [[UINavigationBar appearance] setTitleTextAttributes:navbarTitleTextAttributes];


    }
    else
    {
        UIColor * barColor = [UIColor
                              colorWithRed:73.0/255.0
                              green:208.0/255.0
                              blue:114.0/255.0
                              alpha:1.0];
        [self.navigationController.navigationBar setTintColor:barColor];

    }

}

最佳答案

我遇到了同样的问题。 通过关闭 Storyboard 中根导航 Controller 的导航栏属性中的“Transcluent”复选框进行修复。 您需要打开名为“Document Outline”的左 Pane ,左下角有小按钮以找到导航栏。

关于ios - UINavigationBar 变黑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20372860/

相关文章:

ios - 我的 UICollectionView 中没有 ItemSelected 调用?

ios - 已安装字体列表

iphone - 如何将 uitableview 选择与 indexpath 值居中

ios - Swift:如何在使用 XLPagerTabStrip 中的 subview Controller 后返回到第一个 View Controller

ios - 导航 Controller 中的后退按钮到底是做什么的?

ios - 保存搜索结果 xcode

javascript - 在 sencha 的主视图中包含多个 View

iphone - 如果@2x 图像可用但常规分辨率图像不可用,会发生什么情况?

ios - UIImagePickerController 解雇时使用 UITabbarcontroller 获取带有应用程序名称的红色条

ios - 将 Cocos3D 添加到现有的 XCode/iOS 项目