从iOS导航后退栏按钮中删除文本。

时间:2013-07-20 19:29:13

标签: ios uinavigationcontroller uibarbuttonitem

我想删除左侧导航栏中的文字,但我到处都看不到任何内容。我希望按钮只显示一个图像,它会这样做,但文本覆盖它。如何删除文本?

2 个答案:

答案 0 :(得分:1)

UIImage* image = [UIImage imageNamed:@"yourImage"];
CGRect frameimg = CGRectMake(0, 0, image.size.width, image.size.height);
UIButton *yourButton = [[UIButton alloc] initWithFrame:frameimg];
[yourButton setBackgroundImage:image forState:UIControlStateNormal];
UIBarButtonItem *button =[[UIBarButtonItem alloc] initWithCustomView:yourButton];
self.navigationItem.rightBarButtonItem=button;

答案 1 :(得分:0)

只需设置

self.navigationItem.title = @"";

在上一个viewcontroller中