Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

changing the height of UITabBar in iOS7/8?

I am trying to change the height of the stock UITabBar to 44px, similar to Tweetbot's tab bar height. I've also seen a few other apps do this as well.

however, when i try to set the height it still remains the same

self.tabBar.frame.height = 40

are we not allowed to change the tab bar height? and if so what is a good alternative? using a toolbar?

like image 979
3254523 Avatar asked Jun 24 '14 22:06

3254523


People also ask

How do I increase the size of my tab bar?

Open Google Chrome. Type chrome://flags/#scrollable-tabstrip in the address bar, and hit the Enter key. From the drop-down menu next to the Scrollable Tabstrip option, select one of the following options: Enabled - tabs shrink to pinned tab width.


3 Answers

It seems everybody says this can't be done easily

In your storyboard give your UITabBar a custom subclass name, then implement the subclass with the following

This tells all views that use the tab bar that it should be a certain height.

@implementation MyTabBar

-(CGSize)sizeThatFits:(CGSize)size
{
    CGSize sizeThatFits = [super sizeThatFits:size];
    sizeThatFits.height = 100;

    return sizeThatFits;
}

@end

enter image description here

like image 144
SomeGuy Avatar answered Nov 28 '22 18:11

SomeGuy


SomeGuy's answer above worked for me. Here's the Swift translation for anyone who may need it. I made the height close to what it seems most popular apps use.

class TabBar: UITabBar {

     override func sizeThatFits(size: CGSize) -> CGSize {
         var sizeThatFits = super.sizeThatFits(size)
         sizeThatFits.height = 38

         return sizeThatFits
     }
}
like image 35
Melly Avatar answered Nov 28 '22 18:11

Melly


For Swift 3 and xcode 8

extension UITabBar {
     override open func sizeThatFits(_ size: CGSize) -> CGSize {
     var sizeThatFits = super.sizeThatFits(size)
     sizeThatFits.height = 80 // adjust your size here
     return sizeThatFits
    }
 }
like image 35
Museer Ahamad Ansari Avatar answered Nov 28 '22 17:11

Museer Ahamad Ansari