简体   繁体   English

如何增加UITabbar的大小

[英]How to increase the size of UITabbar


I have to increase the height of UITabbar. 我必须增加UITabbar的高度。 How can I do this any help please? 请问我该怎么办?

You change its height, width, x and y coordinates. 您可以更改其高度,宽度,x和y坐标。 See this: 看到这个:

CGRect viewFrame=self.tabBar.frame;
        //change these parameters according to you.
        viewFrame.origin.y -=50;
   viewFrame.origin.x -=20;
   viewFrame.size.height=200;
   viewFrame.size.width=300;
        self.tabBar.frame=viewFrame;

You can change these parameters for tabBar not tabBar controller in case of tabBased app selected in starting when you select the app type. 如果在选择应用类型时选择了tabBased应用,则可以更改tabBar而不是tabBar控制器的这些参数。

You can write a category of UItabbar 您可以编写一个UItabbar类别

here is the code : 这是代码:

.h file : .h文件:

#import 

@interface UITabBar (NewSize)
- (CGSize)sizeThatFits:(CGSize)size;
@end

.m file : .m文件:

#import "UITabBar+NewSize.h"

@implementation UITabBar (NewSize)
- (CGSize)sizeThatFits:(CGSize)size {
    CGSize newSize = CGSizeMake(size.width,44);
    return newSize;
}
@end

and then #import "UITabBar+NewSize.h" 然后#import“UITabBar + NewSize.h”

self.tabBarController = [[UITabBarController alloc] init];
[self.tabBarController.tabBar sizeThatFits:CGSizeMake(320, 44)];
self.tabBarController.tabBar.shadowImage = [[UIImage alloc]init];  //delete the default tabbar shadow!

I have seen posts of many people about the same similar thing. 我见过很多人关于同样类似事情的帖子。 The only solution they came up with is sub classing the UITabbar. 他们提出的唯一解决方案是对UITabbar进行子类化。 May be you can do that. 也许你可以做到这一点。

This goes against the iOS Design Guidelines, but if you have to do it, you may subclass your tabbar-controller and alter it. 这违反了iOS设计指南,但是如果你必须这样做,你可以将tabbar-controller子类化并改变它。 It will not look good just changing the height. 改变高度看起来不太好看。

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

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