Yurkevich
Yurkevich

Reputation: 4517

Remove navigation bar back button title without breaking transition

In iOS 7 Apple introduced new transition when you push view controller on top of another view controller. The transition comes with nice animation and back gesture. The back button displays the title from previous view controller which is good for accessibility:

Navigation Bar in Apple Health

  1. You know where you are by looking on a title. You know that title is not intractable because it has different to tint color, usually, black.
  2. You know where you come from with the back button label.

Unfortunately, our design require to remove navigation bar label because sometimes it is too long and it move navigation bar title to the right a little.

Here is how our design should look and work during the transition:
SoundCloud app

We removed the title from the first view controller in viewDidLoad of the first view controller (the one which is behind):

- (void)viewDidLoad {
[super viewDidLoad];

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

Now our transition has status bar background color problem:
Our app transition

Status bar change background color to grey during transition. Both view controllers have white status bar background.

Pushing second view controller:

SecondVC *svc = [sb instantiateInitialViewController];
[self.navigationController svc animated:YES];`

Upvotes: 0

Views: 488

Answers (2)

Rohit Khandelwal
Rohit Khandelwal

Reputation: 1778

In first ViewController -

-(void)viewWillAppear:(BOOL)animated{

[super viewWillAppear:YES];

UIBarButtonItem *btn=[[UIBarButtonItem alloc]initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:nil];

self.navigationItem.backBarButtonItem=btn;

}

Upvotes: 0

Yurkevich
Yurkevich

Reputation: 4517

The solution is to remove this line from our code:

[[UINavigationBar appearance] setBackgroundColor:Colour_White];

Upvotes: 0

Related Questions