How do i remove text from back button on navbar within Xcode?

后端 未结 8 1930
醉酒成梦
醉酒成梦 2021-02-09 05:49

I set an arrow custom image to navigation bar by adding the following code in app delegate, it works but now im looking to remove the text completely for back button.

         


        
8条回答
  •  情话喂你
    2021-02-09 06:05

    I really don't think is a good practice for a developer to adjust the offset of the text in order to hide it.

    A cleaner solution would be to just add to the navigation controller back button a new button where the title is an empty string. You should add this in the previous calling view controller in viewWillAppear (not the current one):

    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
    self.navigationItem.backBarButtonItem = backButton;
    

提交回复
热议问题