Will Jenkins
Will Jenkins

Reputation: 9887

Adding a sliding panel to a UITabBarController

I've made a panel with a tab that can be dragged up from the bottom of the screen.

I'd like to add this to a UITabBarController so that it is present on all the tabBar subviews, but is has to appear to slide out from the top of the tab bar itself. I can add the panel to the same top-level view as the UITabBarController, but it slides over the top of the tab bar.

Is there a subview in the UITabBarController where this slider could be added that would make it behave as desired without the pain of cropping off the bottom of the panel view programmatically?

Upvotes: 1

Views: 873

Answers (1)

rdurand
rdurand

Reputation: 7410

You can try this, which will work for iOS 5+ (this is using a storyboard) :

• Create a subclass of UITabBarController (I'll call it "TabViewController").

• In your storyboard, select your UITabBarViewController, and give it the class `TabViewController (on the right bar, 3rd section, custom class).

• In your TabViewController.m file, use this code :

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    UIView *theView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 50, 50)];
    theView.backgroundColor = [UIColor redColor];
    [self.view addSubview:theView];

    [self.view bringSubviewToFront:self.tabBar];
}

You can do whatever you want with theView before you add it to self.view, here I just create a 50x50 red square at the position (50, 50). The view will be behind the TabBar and stay over your ViewControllers.

Here, theView would be your own control (your "tab that can be dragged up from the bottom of the screen").

Upvotes: 5

Related Questions