Reputation: 21553
With the new customization APIs in iOS 5, is it possible to increase the height of UITabBar? If not, what are some open source options if I want to target iOS 5? Thanks
Upvotes: 2
Views: 6815
Reputation: 851
You can write a category of UItabbar
here is the code :
.h file :
#import <UIKit/UIKit.h>
@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!
Upvotes: 2
Reputation: 781
My way of customizing UITabBarController's tabbar is to customize UITabBarController itself first.
UITabBarcontroller has two subviews inside. A UITransitionView and a UITabBar. UITransitionView is the area on the top half of the screen where you put your view controllers in.
In order to customize the height of the UITabbar, you also need to edit UITransitionView's frame. So, for instance if you want to change the heights, you can do;
[[tabbarController.view.subviews objectAtIndex:0] setFrame:CGRectMake(0, 0, 320, 440)];
[tabbarController.tabBar setFrame:CGRectMake(0, 440, 320, 50)];
This will create a 50 px height tabbar, (by default it is 48 px)
Upvotes: 9
Reputation: 12325
You cannot do that with the UITabBar
. I would suggest that you create your own UIToolBar
and make it appear like a tabBar, and you can add UIButtons
to it and make them appear like tabBarItems
.
It will appear like a tabBar
and gives you a lot of room for customizations and you can also add more than 5 tabs to it and implement a "scroll" animation between the buttons. :)
Upvotes: 1
Reputation: 388
I would suggest the BCTabBarController. I used it in one of my projects and it works great. You would still have to customize it, though.
Upvotes: 0
Reputation: 236
It's not possible with the UIAppearance proxy
The way I'd recommend doing it is using container ViewController methodology in UIViewController (It's under the heading Implementing a Container View Controller). Apple's docs basically tell you how to roll your own.
Upvotes: 0