【问题标题】:UINavigationBar becomes blackUINavigationBar 变黑
【发布时间】:2013-12-04 10:30:28
【问题描述】:

首先,当我调用 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];

    }

}

【问题讨论】:

  • 在你的情况下:if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)7 不是浮点值,把它改成7.0
  • 尽管我将半透明改为不透明,但它仍然变黑。更改为浮动也无济于事
  • 你找到解决这个问题的方法了吗?

标签: ios iphone uinavigationcontroller uinavigationbar


【解决方案1】:

我遇到了同样的问题。 通过关闭情节提要中我的根导航控制器的导航栏属性中的“透明”复选框来修复。 您需要使用左下角的小按钮打开名为“文档大纲”的左侧窗格才能找到导航栏。

【讨论】:

猜你喜欢
  • 2015-08-26
  • 2014-05-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多