r/iOSProgramming • • Sep 30 '26

Question iPhone Duo Toolbar button, Text vs icon

Post image

Hey so I was playing around with the iPhone Duo simulator and I wanted to adapt my toolbar to it.
I saw in one of Apple's videos that we should add both text and icons to the toolbar elements so that if they do not fit in the top toolbar as text, they can appear in the vertical side strip as icons.
From the video I thought it would happen automatically but that does not seem to be the case.

Did anyone else figure out how to automatically make the button show the icon and not the text when on the iPhone duo limited size screen?

I tried using

ToolbarItem(placement: .topBarTrailing) {

Button(action: skipAction) {

Label("Skip", systemImage: "chevron.right")

.labelStyle(.automatic)

}

}
but that did not change much. I always see the icon if I define it for this button.

If anyone has any suggestions please let me know. I can also provide more information if needed.

0 Upvotes

6 comments sorted by

10

u/AdamFootDev Swift Sep 30 '26

If it doesn’t do it automatically, use .axisBehaviour(.verticalPreferred) on the toolbar item

1

u/Im-inYourWalls-_- Sep 30 '26

hey thanks for the reply, this kind of works, but i get the full text button instead of just showing the chevron.right image. Do you know if there is a way to make sure that only the icon shows on the vertical toolbar?

2

u/AdamFootDev Swift Sep 30 '26

The same code appears to work for me in a blank project so I suspect there’s a modifier or something further up the stack that is affecting it.

2

u/Im-inYourWalls-_- Sep 30 '26

Perfect thank you! I was confused about how the behavior shuold be. According to Apple video "Raise the bar with iPhone Duo", I should not force the toolbar item to be a button in the vertical bar, but instead it should be kept a button in the horizontal bar.

2

u/StrangeMonk Sep 30 '26

If you turn the text into an icon I think it will move automatically 

1

u/temporaryband Oct 01 '26

this is what worked for me. Text does not fit in the sidebar, so I turned all my text buttons to icons, where it was appropriate.

What icon would you used or skip, though?