How to increase the size of UITabbar

 ̄綄美尐妖づ 提交于 2019-12-21 20:56:45

问题



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


回答1:


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.




回答2:


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!



回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/5230128/how-to-increase-the-size-of-uitabbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!