iPhone Programmatically
iPhone Programmatically

Reputation: 1227

Show the bottom bar on every view

I want to have this bottom bar on every UIViewController, I took this as tab bar first, but then I changed it to UIView because I need to scroll the bar as it contains more buttons, but now the issue is how to show this bar on every UIViewController and where I should declare this. Can anyone guide me for that.

Thanks in advance.

UIview

This way I set UIView as bottom bar in one of UIViewController.

viewBotBar = [[UIView alloc]initWithFrame:CGRectMake(0, 380, 320, 79)];
viewBotBar.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"1aa.png"]];
[self.view addSubview:viewBotBar];

Upvotes: 1

Views: 112

Answers (4)

Paras Joshi
Paras Joshi

Reputation: 20551

just add this view in window for every view like bellow..

write this method in AppDelegate.m file and call this method after add rootViewController..

-(void)addCustomBottomBar{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.window cache:YES];

    viewBotBar = [[UIView alloc]initWithFrame:CGRectMake(0, 380, 320, 79)];
    viewBotBar.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"1aa.png"]];
    [self.window addSubview:viewBotBar];
    [self.window bringSubviewToFront:viewBotBar];

    [UIView commitAnimations];
}

UPDATE:

see these links for Custom TabBar..

  1. Custom TabBar
  2. RXCustomTabBar

Upvotes: 1

Nitin Gohel
Nitin Gohel

Reputation: 49730

hi my dear Friend i just google it and i found Best tutorial for you please download bellow link's example:-

https://github.com/a1phanumeric/PeekabooTabBarController

hear is the demo Image:-

enter image description here

Hope its helps you al the very best :)

Upvotes: 3

user1673099
user1673099

Reputation: 3299

You can create one class file. Then implement one method for custom Tab & try to call this method on every View controller. Then add this bar with object of that class.

Upvotes: 0

SachinVsSachin
SachinVsSachin

Reputation: 6427

Firstly Access the window object like

 UIWindow *window = [UIApplication sharedApplication].keyWindow;
viewBotBar = [[UIView alloc]initWithFrame:CGRectMake(0, 380, 320, 79)];
viewBotBar.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"1aa.png"]];
window addSubView:viewBotBar];

Upvotes: 0

Related Questions