【问题标题】:text disappear when setting image to navBar将图像设置为导航栏时文本消失
【发布时间】:2011-09-14 14:03:01
【问题描述】:

我在导航栏显示图像,但标题消失了,为什么?

如何解决?

 - (void)viewDidLoad {
[super viewDidLoad];

UIImage *image = [UIImage imageNamed:@"navbar.png"];

 UIImageView *imageView = [[UIImageView alloc]initWithImage:image];
self.navigationItem.titleView=imageView;
[imageView release];
 // self.title = @"Bio"; 
self.navigationItem.title = @"Bio";
}

非常感谢!

【问题讨论】:

    标签: ios image text navbar


    【解决方案1】:

    您已将标题视图替换为图像视图,因此导航栏无法再显示标题。

    如果你想要文本和图像,你需要添加一个带有UILabel 子视图作为titleView 的图像视图,并设置UILabel 的文本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-21
      • 1970-01-01
      • 1970-01-01
      • 2016-02-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多