Only image as UITabBarItem

后端 未结 9 2071
伪装坚强ぢ
伪装坚强ぢ 2021-02-01 05:29

I would only like to have an icon as the UITabBarItem and not the text underneath and I was wondering if this was possible, if so, how? TIA

9条回答
  •  闹比i
    闹比i (楼主)
    2021-02-01 05:54

    if you just set the image and pass nil to title, the image will be displayed at the top level of the UITabBar item. You have to set the position also.

    int offset = 7;
    UIEdgeInsets imageInset = UIEdgeInsetsMake(offset, 0, -offset, 0);
    

    After you set icon image for TabBarItem, you set the property value to change the image position, doing:

    uiViewController.tabBarItem.imageInsets = imageInset;
    

提交回复
热议问题