Right now when creating a standard UITabBarItem, the Image is vertically above the text. But when playing around with the offset for both the title and image, it doesn't maintain its center alignment and instead just makes it look offset (like the name describes, duh). How can I accomplish this? Before it seemed to be a "feature" of iOS, but as of now I cannot find any other SO questions or tutorials online that explain how to do this. I've thought about subclassing a UITabBarItem, but what would change the way the system lays out the title/image? Would I need to manually change the frame of the title/imageview and if so, how would I do that?
Asked
Active
Viewed 152 times
1
-
Not an answer, just a thought: render the intended look into an image and only assign the image to the tab bar item? Would interfere with VoiceOver, though, so vision impaired people wouldn't know what these represent. – DarkDust Mar 06 '19 at 17:27
-
Dam @DarkDust that would be a great idea, however we need the app to be accessible. – Jay Mar 06 '19 at 17:48
-
@DarkDust Do you think if I used your idea for the image, and still kept the text, but set the font color to clear, that it would still provide accessibility for the vision impaired? – Jay Mar 06 '19 at 23:02
-
I think this may work, yes. At least worth giving it a try. – DarkDust Mar 07 '19 at 08:04
-
@DarkDust So setting the title Font to clear affects the rest of the tabBarItem as well. So the image becomes clear. HOWEVER, if you set the Y axis offset for the title so it goes off screen, then you can accomplish it..I believe? What do you think. – Jay Mar 07 '19 at 17:19
-
@DarkDust if you want to leave an answer, with what you suggested, I will mark it as the correct since that is what I will be doing. Thank you for your help! – Jay Mar 08 '19 at 17:35
-
Thanks, I've added an answer. :-) – DarkDust Mar 09 '19 at 07:30
1 Answers
0
One way to solve this is to render an icon with text positioned in the image the way you want it and hide the title of UITabBarItem
.
Changing the text color of the title only seems to work for all items, but you can push it out-of-view using UITabBarItem
's titlePositionAdjustment. This way the title rendered by UIKit isn't visible any more but still works with Voice Over.

DarkDust
- 90,870
- 19
- 190
- 224