简体   繁体   English

将图像添加到基于选项卡的应用程序的导航栏

[英]Adding image to navigation bar of tab based application

I have tab base application I want to add logo to the navigation bar I tried 我有标签基础应用程序,我想将徽标添加到我尝试过的导航栏中

  • (void)viewDidLoad { [super viewDidLoad]; (void)viewDidLoad {[super viewDidLoad];

    // add image // 添加图片

    UIImage *image = [UIImage imageNamed:@"test.png"]; UIImage * image = [UIImage imageNamed:@“ test.png”]; UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; UIImageView * imageView = [[UIImageView分配] initWithImage:image]; self.navigationItem.titleView = imageView; self.navigationItem.titleView = imageView;

} }

but no image be displayed any suggestion to solve that 但不会显示任何图像来解决该问题

best regards 最好的祝福

Try with setting frame of UIImageView *imageView ... 尝试设置UIImageView *imageView框架...

imageView.frame = CGRectMake(myX,myY,muWidth,myHeight)

Let me know if you still struggle ... 让我知道您是否仍在努力...

Do you have your leftBarButtonItem set? leftBarButtonItem设置了leftBarButtonItem In the docs it says for titleView property of UINavigationItem : This property is ignored if leftBarButtonItem is not nil. 在文档中,它表示UINavigationItem titleView属性:如果leftBarButtonItem不为nil,则忽略此属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM