2

I've followed this code to implement a title and subtitle in the navigation bar: iPhone Title and Subtitle in Navigation Bar which works really well. However, I have a section where I've hidden the back button by doing:

self.navigationItem.hidesBackButton = YES;

and I'd like the title to take up the extra room on the left where the button used to be.

Is this possible?

Community
  • 1
  • 1
Dave
  • 493
  • 9
  • 22

1 Answers1

4

Set the origin of navigationItem.titleView

For example

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    if (self.navigationItem.hidesBackButton) {
        CGRect frame = self.navigationItem.titleView.frame;
        frame.origin.x = 10;
        self.navigationItem.titleView.frame = frame;
    }
}
sutee
  • 57
  • 1
  • 3