添加徽标到UINavigationBar

时间:2012-10-25 16:52:16

标签: objective-c ios

我将以下代码添加到我的应用代理中以将我的徽标提供给UINavigationBar,但它无法正常工作。我在项目中有Logo.png和Logo@2x.png。

我做错了什么?

UIImageView *titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Logo.png"]];
[[UINavigationBar appearance] setTitleView:titleView];

2 个答案:

答案 0 :(得分:0)

是的,iOS区分大小写。再试一次,但要改变:

UIImageView *titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Logo.png"]];

UIImageView *titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logo.png"]];

答案 1 :(得分:0)

如果我理解你的问题,那么你想要做的是在你的ViewController的导航项中设置tileImage,如下所示:

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Set up the nav bar
    UIImage *titleImage = [UIImage imageNamed:@"Logo.png"];
    self.navigationItem.titleView = [[UIImageView alloc] initWithImage:titleImage];
}