Reputation: 8432
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?
Upvotes: 0
Views: 821
Reputation: 1297
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.
Upvotes: 0
Reputation: 5590
I would use UIViewControllerContainment. Take a look at
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
Upvotes: 1