self.navigationItem.title发行iOS7

self.navigationItem.title发行iOS7,ios7,uinavigationitem,Ios7,Uinavigationitem,我就是不能在navigationItem上加任何标题 self.navigationItem.title = @"My Account"; 我没有看到任何反对的警告,有人知道吗 谢谢, self.navigationController.navigationItem.title = @"My Account"; 找到了一种方法: [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dict

我就是不能在navigationItem上加任何标题

self.navigationItem.title = @"My Account";
我没有看到任何反对的警告,有人知道吗

谢谢,

self.navigationController.navigationItem.title = @"My Account";
找到了一种方法:

[self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     [UIColor whiteColor],UITextAttributeTextColor,
                                                                     [UIColor whiteColor], UITextAttributeTextShadowColor,
                                                                     [UIFont fontWithName:@"HelveticaNeue-Bold" size:16.0], UITextAttributeFont, nil]];
    self.navigationItem.title = @"My Account";

您需要设置TextAttributes,否则将无法工作。

更新答案以替换不推荐的属性

[self.navigationController.navigationBar 
    setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
    [UIColor whiteColor],NSForegroundColorAttributeName,
    [UIColor whiteColor], NSShadowAttributeName,
    [UIFont fontWithName:@"HelveticaNeue-Bold" size:16.0], NSFontAttributeName, nil]];

什么是导航项?它是您创建的还是您正在使用导航控制器?导航控制器,在iOS6中,在self.navigationItem.title=@“我的帐户”之前;这对我来说很有效,但我们不得不这么做似乎有点傻。知道为什么现在需要这样做吗?