Is it possible to have a UITabBarItem without an image, but with large text?

Is it possible to have a UITabBarItem without an image, but with larger text?

for example: have text at full height?

+3
source share
3 answers

Of course, just create an image of a larger text. As far as I know, this is the only way.

+4
source

Yes, you can initialize it with a blank image as follows:

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

Only the title text is displayed.

+1
source

.

tabBarItem. tabBarItem , .

- (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;
}

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)];
}
0

Source: https://habr.com/ru/post/1751069/


All Articles