Ios 更改在情节提要中拖动的导航栏的标题

Ios 更改在情节提要中拖动的导航栏的标题,ios,objective-c,uinavigationbar,Ios,Objective C,Uinavigationbar,我想更改我从调色板中拖入故事板的导航栏标题的字体和颜色(不是使用nag控制器+推送序列自动创建的)。 我已经试过了 self.navigationController.topViewController.title = @"title"; self.title = @"title"; self.navigationItem.title = @"title"; 但它们都不起作用。没有显示标题,所以我甚至没有尝试更改字体或颜色。 如何修复?确保导航栏是某个navigationController的

我想更改我从调色板中拖入故事板的导航栏标题的字体和颜色(不是使用nag控制器+推送序列自动创建的)。 我已经试过了

self.navigationController.topViewController.title = @"title";
self.title = @"title";
self.navigationItem.title = @"title";
但它们都不起作用。没有显示标题,所以我甚至没有尝试更改字体或颜色。
如何修复?

确保导航栏是某个navigationController的一部分

试试这个:

self.navigationController.navigationBar.tintColor = [UIColor whiteColor];

[self.navigationController.navigationBar setBackgroundImage: [UIImage imageNamed:@"NavBarColor"] forBarMetrics: UIBarMetricsDefault];

self.navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName];

self.title = @"Title here!";
否则:

 UILabel* titleLabel = [[UILabel alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 170.0f, 44.0f)];

    titleLabel.backgroundColor = [UIColor clearColor];
    titleLabel.textAlignment   = NSTextAlignmentCenter;
    titleLabel.textColor       = [UIColor colorWithRed: 0.922f green: 0.925f blue: 0.973f alpha: 1.0f];
    titleLabel.font            = [Utils helveticaBoldFontOfSize: 19.333f];
    titleLabel.text            = NSLocalizedString(@"Title Here", nil);
    self.navigationItem.titleView = titleLabel;
这是行不通的;(视图控制器未直接嵌入navig控制器中,但我是通过一个模态序列从一个带有导航控制器的视图中获取此视图的,这可能是问题所在吗?