Allreadyhome
Allreadyhome

Reputation: 1262

Custom Top Navigation Bar

I am trying to replicate the similar layout options that have become popular in a lot of apps recently.

enter image description here

This is with a button on the left and right and two options in the middle.

I have been looking at creating a custom container view and replicating the navigation menu with my own custom made navigation however I'm not sure if this is the most efficient way to achieve this.

I know how to add multiple buttons using the following but this doesn't provide the option to position buttons in the middle of the navigation menu.

UIBarButtonItem *editBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(editAction)];

Can I get some suggestions about where to look to achieve this look? I have looked around but the terms of my search might be wrong.

Upvotes: 0

Views: 44

Answers (1)

Santiago Fabregat
Santiago Fabregat

Reputation: 686

You should create a custom UISegmentedControl and the put in the navigation bar:

- (void)viewDidLoad {
    [super viewDidLoad];

    self.navigationItem.titleView = self.customSegmentControl;
}

And for the background you should use an image created by you, and call it in the App Delegate if your are going to use the same one throughout the whole app or in the View Controller for that particular window:

[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar.png"] forBarMetrics:UIBarMetricsDefault];

Upvotes: 1

Related Questions