user3810193
user3810193

Reputation: 53

Use UISegmentedControl to build a menu like this?

I'm trying to build a menu like this with Xcode 13 Swift 5.

Each item has different width, but the margin between two items are always the same. Additionally, the highlighting is also dynamic to text width. There will also views attached to each selected item.

Would it be possible to achieve it with UISegmentedControl?

thanks!

Upvotes: 1

Views: 75

Answers (1)

Jawad Ali
Jawad Ali

Reputation: 14417

You can achieve this using UIStackview.

Look at the configuration that I have developed for you. Selected font color of the button is white and background color black otherwise font color black and bg blue. On selecting any button deselect the previous one, and boom: achieved.

enter image description here

Upvotes: 1

Related Questions