简体   繁体   English

是否可以修改uitabbarcontroller的高度?

[英]Is it possible to modify uitabbarcontroller height?

我听说,如果您从底部移动选项卡栏,那么您的应用将被拒绝,因为这违反了他们的政策,但是我想修改高度并添加admob横幅视图和一些按钮,如果这样做,将被拒绝?

You can change the tabBar height like this: 您可以这样更改tabBar的高度:

CGRect viewFrame=self.tabBar.frame;
        //Sample parameters, add what fits your needs
        viewFrame.origin.y -=30;
   viewFrame.origin.x -=10;
   viewFrame.size.height=150;
   viewFrame.size.width=200;
        self.tabBar.frame=viewFrame;

This is for UITabBar not tabBarController in case you created a tab-based project. 如果您创建了基于选项卡的项目,则此选项适用于UITabBar而不是tabBarController。

Your app might not be rejected. 您的应用程序可能不会被拒绝。 Just because you change the control object of tab doesn't mean any security issues. 仅因为更改了tab的控件对象并不意味着任何安全问题。 For example, apple's own app store app on iPad is a tab bar controller, but the control object is uisegmentcontrol object. 例如,iPad上苹果自己的应用程序商店应用程序是一个标签栏控制器,但控件对象是uisegmentcontrol对象。

You can hide or change the tab bar in a tab bar controller very easily. 您可以非常轻松地隐藏或更改标签栏控制器中的标签栏。 The following code should explain it easily. 下面的代码应该很容易地解释它。

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

    self.tabBar.hidden = YES;

    for(UIView *view in self.view.subviews) {
        if([view isKindOfClass:[UITabBar class]]) {
            [view setFrame:CGRectMake(view.frame.origin.x, self.view.frame.size.height+49, view.frame.size.width, view.frame.size.height)];
        }
        else {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, self.view.frame.size.height)];
        }

    }
}

Also I suggest you give more thought to this method. 我也建议您多考虑一下这种方法。 Container Controllers . 容器控制器

However, if apple rejects you can change things very easily. 但是,如果苹果拒绝,您可以很轻松地进行更改。 Don't worry a lot to try something new. 不必担心尝试新事物。 Maybe apple will get your idea and pay you some royalty to use even :P. 也许苹果会得到您的想法,并付给您一些使用费,甚至:P。

AFAIK, it's not possible to modify the height. AFAIK,无法修改高度。 You have to customize the tabbarcontroller to achieve this. 您必须自定义tabbarcontroller以实现此目的。

Try the sample project for this in Github. 在Github中尝试示例项目

And what about contentViewController? 那contentViewController呢? Because if you change heigth (and move position.y), you should increase viewcontroller size too, isn't it? 因为如果您更改高度(并移动position.y),那么您也应该增加ViewController的大小,不是吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM