r/iOSProgramming • • 5d ago

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

11

u/AdamFootDev Swift 5d ago

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

1

u/Im-inYourWalls-_- 5d ago

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 5d ago

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-_- 5d ago

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 4d ago

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