0

What is the best way to add a topbar(View) in a tabbar iOS application that always remain on top of all the views, irrespective of which tab is selected like the image below?

enter image description here

Community
  • 1
  • 1
hariszaman
  • 8,202
  • 2
  • 40
  • 59

2 Answers2

1

I would use UIViewControllerContainment. Take a look at

https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html

The way I'd set it up is have a UIViewController that has two ContainerViews. One ContainerView will have the UITabBarController in it and the other would have the UIViewController for the top bar.

Here is what I did in a UIStoryboard enter image description here

aahrens
  • 5,522
  • 7
  • 39
  • 63
0

Subclass UIViewController and change the title and title view in the viewDidLoad: method with something like this:

- (void)viewDidLoad
{
  [super viewDidLoad];

  if (!self.title || [self.title isEqualToString:@""]) {
      self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Logo.png"]];
  } else {
      self.navigationItem.title = self.title;
  }
}

Then use this subclass on all the view controllers that you will have in your tabs.

Juan de la Torre
  • 1,297
  • 9
  • 19