Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use UITabBar without images... means with text only

I want to use UITabBar but without images. I want the text to occupy full control space. i tried setting image to nil, but text is small and aligned to bottom of tabbaritem.

like image 541
Osama F Elias Avatar asked Oct 22 '10 16:10

Osama F Elias


2 Answers

This function changes the font of all UITabBarItems:

[[UITabBarItem appearance] setTitleTextAttributes: aNSDictionaryOfTextAttributes];

you can specify the font type and size with a dictionary of attributes similar to those found in this answer here. And then negatively offset the vertical position of the text with this:

[[UITabBarItem appearance] setTitlePositionAdjustment:UIOffsetMake(0.0, -18.0)];
like image 88
Jeremy Avatar answered Oct 21 '22 07:10

Jeremy


Copy this to your didFinishLaunchingWithOptions.

NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:17.0], NSFontAttributeName, nil];
[[UITabBarItem appearance] setTitleTextAttributes:attributes forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitlePositionAdjustment:UIOffsetMake(0.0, -13.0)];
like image 22
SmallChess Avatar answered Oct 21 '22 08:10

SmallChess