r/iOSProgramming • • 1d 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!

5 Upvotes

10 comments sorted by

2

u/Ornery_Zombie9460 8h ago

I'd be careful shipping that _UILiquidLensView find, even though it looks exact. I went down the same path with a private view once and the trade-off wasn't worth it: it can get flagged in review, and a point release can change the private layout and leave you with a broken tab bar. What I ended up shipping instead was the close-enough version — a capsule with matchedGeometryEffect — and I spent the time on the drag physics instead, a spring with a fairly stiff response so the pill lags the finger slightly and then snaps into place. It still isn't the native wobbly lens, but that lag-and-snap is what made it feel native in use, not the exact glass shape.

1

u/Brilliant_Water8552 8h ago

Do you mind sharing what App you shipped and where I can find that exact control? Sounds interesting and I would like to take a look!

1

u/Brilliant_Water8552 9h ago

For anyone wondering, I have an update. I found the private UIKit API _UILiquidLensView, which exactly is that Wobbly Glass Pill, and can easily be used to make exactly what I am trying to do, though, in the Apple App Review Guidelines Rule 2.5.1 it permits the use of private APIs, which still lets the question open how the Cha tGPT App and the Telegram App (which most likely also uses the private API) got through Apple Review.

1

u/kironet996 7h ago

im pretty sure chatgpt is just using the UISegmentedControl

1

u/Brilliant_Water8552 7h ago

Without the background of it, which is not possible to do when using the native SwiftUI segmented picker.

1

u/kironet996 7h ago

yeah, need to use uiviewrepresentable, i haven't tried it but you can hide the segmented control background

1

u/Sea_Wrongdoer_3500 1d ago

dont think theres a public api that gives you just the pill, but you can get pretty close yourself

basic idea: HStack of your items, pill is a capsule behind the selected one with matchedGeometryEffect so it slides on tap. for dragging, add a DragGesture on the whole row, move the pill with the finger (clamp to the row), and on end snap to the nearest item with a spring. thats most of the "native" feel tbh, the spring + snap

on ios 26 you can make the pill glass with .glassEffect(.regular.interactive()) inside a GlassEffectContainer, and give it a glassEffectID so it morphs between positions instead of just sliding. the interactive part gives you that little stretch/press reaction

also quick haptic (sensoryFeedback .selection) every time the pill crosses into a new item, people notice when thats missing

no idea how chatgpt does it internally tho

1

u/Difficult_Duty2198 14h ago

might be worth trying a real TabView and hiding just the bar background with toolbarBackground(.hidden, for: .tabBar). you keep the system pill and drag behavior, though you'd have to hide the labels some other way.

0

u/ThanhDongNguyen 1d 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.

1

u/Brilliant_Water8552 1d 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.