3

Is it possible to have UITabBarItem without image, but with bigger text instead?

e.g.: to have text with full height?

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
marko
  • 1,336
  • 2
  • 12
  • 25

3 Answers3

4

Sure, just make an image of the larger text. As far as I know, that's the only way.

Ben S
  • 68,394
  • 30
  • 171
  • 212
1

Yes, you can initialise it with an empty image like this:

 UIImage* image = [[UIImage alloc] init];
 tabBarItem = [[UITabBarItem alloc] initWithTitle:title image:image tag:tag] ;
 [image release];

Only the title text will be displayed.

Sam
  • 3,659
  • 3
  • 36
  • 49
0

Full solution is here.

You need to set empty image to tabBarItem. Otherwise tabBarItem will not appear until you tap it.

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

        self.tabBarItem.title = @"Report";
        self.tabBarItem.image = [[UIImage alloc] init];

    }

    return self;
}

Customization of UITabBar:

- (void)customizeAppearance
{
    [[UITabBar appearance] setBarTintColor:[UIColor blackColor]];
    [[UITabBar appearance] setTranslucent:NO];
    [[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName:[UIColor whiteColor],
                                                         NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue-Thin" size:22]}
                                             forState:UIControlStateNormal];

    [[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName:RGB(0xff9700),
                                                         NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue-Thin" size:22]}
                                             forState:UIControlStateSelected];

    [[UITabBarItem appearance] setTitlePositionAdjustment:UIOffsetMake(0.0, -10.0)];
}
Denis Kutlubaev
  • 15,320
  • 6
  • 84
  • 70