How to increase the size of UITabbar

2020-07-27 03:57发布


I have to increase the height of UITabbar. How can I do this any help please?

4条回答
我只想做你的唯一
2楼-- · 2020-07-27 04:13

This goes against the iOS Design Guidelines, but if you have to do it, you may subclass your tabbar-controller and alter it. It will not look good just changing the height.

查看更多
forever°为你锁心
3楼-- · 2020-07-27 04:16

You can write a category of UItabbar

here is the code :

.h file :

#import 

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

.m file :

#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"

self.tabBarController = [[UITabBarController alloc] init];
[self.tabBarController.tabBar sizeThatFits:CGSizeMake(320, 44)];
self.tabBarController.tabBar.shadowImage = [[UIImage alloc]init];  //delete the default tabbar shadow!
查看更多
家丑人穷心不美
4楼-- · 2020-07-27 04:39

You change its height, width, x and y coordinates. 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.

查看更多
叼着烟拽天下
5楼-- · 2020-07-27 04:39

I have seen posts of many people about the same similar thing. The only solution they came up with is sub classing the UITabbar. May be you can do that.

查看更多
登录 后发表回答