【问题标题】:Remove text from iOS navigation back bar button.从 iOS 导航返回栏按钮中删除文本。
【发布时间】:2013-07-20 19:29:13
【问题描述】:

我想从导航栏左键中删除文本,但我到处找了,找不到任何东西。我希望按钮只显示一个图像,它会这样做,但文本会覆盖它。如何删除文本?

【问题讨论】:

    标签: ios uinavigationcontroller uibarbuttonitem


    【解决方案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;
    

    【讨论】:

      【解决方案2】:

      设置一下

      self.navigationItem.title = @"";
      

      在上一个视图控制器中

      【讨论】:

      • 是的,但这也会删除标题
      猜你喜欢
      • 2020-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多