首先,当我调用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];
}
}
答案 0 :(得分:4)
我遇到了同样的问题。 通过关闭Storyboard中我的根导航控制器的导航栏属性中的“Transcluent”复选框来修复。 您需要打开左侧窗格,名为“Document Outline”,左下角有一个小按钮,以找到导航栏。