Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a common view for all view controllers in UITabbarController

I'm trying to develop something like the playback bar in Apple Music. A common view that appears at the bottom of all the view controllers of a UITabbarContoller. Is there any idea or a best practice to achieve this ? enter image description here

Well, I'll just put down my personal solution

  1. subclass a view controller for the common view.
  2. attach the view controller as the child view controller of the tab bar controller.

I don't really like embedding a view controller to the tab bar controller. Just let me know if there is a better solution.

like image 338
bunnyshell Avatar asked Feb 17 '16 10:02

bunnyshell


2 Answers

UITabBar has UINavigationController which has all the separate UIViewControllers. If you want this view in each tab, then best way to do it is to add it on top of the UINavigationControllers view. It will appear on top of whatever is in UINavigationController.

like image 109
dorian Avatar answered Oct 11 '22 19:10

dorian


You can add that view to window as subview

 [self.window addSubview:vw];

with a tag

 vw.tag = 10000;

so that you can see that view throughout the app

like image 1
Reshmi Majumder Avatar answered Oct 11 '22 17:10

Reshmi Majumder