开发者

text disappear when setting image to navBar

开发者 https://www.devze.com 2023-04-05 08:06 出处:网络
Im showing an image a nav bar,but the title has disappear, why? how to fix it? - (void)viewDidLoad { [super viewDidLoad];

Im showing an image a nav bar, but the title has disappear, why?

how to fix it?

 - (void)viewDidLoad {
[super viewDidLoad];

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

 UIImageView *imageView = [[UIImageView alloc]initWithImage:image];
self.navigationItem.titleView=imageView;
[imageView r开发者_开发技巧elease];
 // self.title = @"Bio"; 
self.navigationItem.title = @"Bio";
}

Thanks a lot!


You've replaced the title view with your image view, so the navigation bar can no longer display a title.

If you want text and an image, you'll need to add an image view with a UILabel subview as the titleView, and set the text of the UILabel.

0

精彩评论

暂无评论...
验证码 换一张
取 消