r/iOSProgramming • • 29m ago

Question How to recreate the native draggable tab bar indicator without the background?

https://streamable.com/rmtbzg

Hey everyone,
I’m currently developing a Swift app and want to recreate the native iOS tab bar interaction, but with just the text labels and the draggable selection pill, without the surrounding tab bar background.
The ChatGPT iOS app implemented pretty much exactly what I’m looking for in a recent update.
I’ve already tried a bunch of different approaches:

  • Modifying existing tab bar recreations on GitHub to remove the background
  • Looking for standalone implementations of the draggable selection pill
  • Exploring projects that use undocumented APIs

Unfortunately, most of these approaches are either too limited or don’t quite capture the native look and feel, especially when it comes to animations and dragging behavior.
Does anyone have an idea how to achieve this? Ideally using public APIs, but I’d also be interested in understanding how ChatGPT implements it.
I’ve attached a screen recording showing exactly what I’m trying to achieve.
Any help would be greatly appreciated!

1 Upvotes

2 comments sorted by

•

u/ThanhDongNguyen 6m ago

I can't say how ChatGPT does it exactly, but I think you can build it without private APIs. The pill is basically a Capsule that moves between the item frames. I would put the tab items in an HStack, store each item frame with a preference key, and draw one capsule behind them with offset and width following the selected index.

For the drag, put a DragGesture with minimumDistance 0 on the whole row and convert the x position to the nearest index. While dragging, let the capsule follow the finger, and on end snap it to the closest item with a spring animation.

If you only target iOS 26, you can fill the capsule with glassEffect(.regular.interactive()). That should give you the glass look and the press feedback, without a background behind the whole bar. I would get the plain version working first and add the glass after the drag feels right.

•

u/Brilliant_Water8552 1m ago

Thanks! I’ve actually considered a similar approach, but the main issue is that the glass provided by glassEffect(.regular.interactive()) doesn’t look or behave the same as the glass used for the native tab bar selection pill. The refraction, distortion, stretching and overall interaction feel noticeably different.
I’m specifically trying to achieve that exact native pill rather than recreate an approximation of it. Since the ChatGPT app seems to have achieved this without the surrounding tab bar background, I’m wondering if there’s a way to reuse the actual system implementation.