Bhumesh Purohit Bhumesh Purohit - 6 months ago 39
Swift Question

Not Remove Navigation back button title

enter image description here

I am IOS Developer. I am using navigation controller. If I push to next page then Back button title always Show "Back". I try all this method for remove titles in viewWillAppear, viewDidload like below. But it is not working for me.

[[UIBarButtonItem alloc] initWithTitle:@""
style:UIBarButtonItemStylePlain
target:nil action:nil];


or

[self.navigationItem.backBarButtonItem setTitle:@""];


or

self.navigationItem.title=@"";


or

self.navigationController.navigationBar.backItem.title =@"";


Thanks in advance.

Answer

Just try this,

[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) 
                                                     forBarMetrics:UIBarMetricsDefault];

or use like this,

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

or use like this,

- (void)layoutSubviews{
    self.backItem.title = @"";
    [super layoutSubviews];
}

Swift

UIBarButtonItem.appearance().UIOffsetMake(0, -60)

or use like

self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: self.navigationItem.backBarButtonItem.style, target: nil, action: nil)

For additional information, Please see [this].(UINavigationBar Hide back Button Text)