在每个视图上显示底部栏

时间:2013-01-02 05:51:18

标签: iphone uiview

我想在每个UIViewController上都有这个底栏,我首先将它作为标签栏,但后来我将其更改为UIView,因为我需要滚动栏,因为它包含更多按钮,但现在问题是如何显示每个UIViewController上的这个栏以及我应该在哪里声明这个。 任何人都可以指导我。

提前致谢。

UIview     

这样我将UIView设置为UIViewController中的一个底栏。

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

4 个答案:

答案 0 :(得分:3)

亲爱的朋友,我只是google它,我找到了最好的教程,请下载bellow link的例子: -

https://github.com/a1phanumeric/PeekabooTabBarController

听到的是演示图片: -

enter image description here

希望它能为你提供最好的帮助:)

答案 1 :(得分:1)

只需在窗口中为每个视图添加此视图,如下图..

AppDelegate.m文件中编写此方法,并在添加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];
}

<强>更新

请参阅自定义TabBar的这些链接..

  1. Custom TabBar
  2. RXCustomTabBar

答案 2 :(得分:0)

首先访问窗口对象,如

 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];

答案 3 :(得分:0)

您可以创建一个类文件。然后为自定义选项卡实现一种方法。尝试在每个View控制器上调用此方法。然后使用该类的对象添加此栏。

相关问题