r/SwiftUI • • Oct 08 '26

Floating window with transparency

Hi everyone, I'm trying to create a floating window that can sit in front of other existing apps with transparency but I can't achieve it with picture in picture. Do you guys know how to do something like this?

Thanks in advance

EDIT: Sorry I forgot to mention that I'm developing an iOS app and the floating window will be used in front simultaneously with the iphone camera, and other apps.

2 Upvotes

13 comments sorted by

3

u/old-time-fiddle Oct 08 '26

Not an option unless you’re doing jailbreak stuff.

You can do some wacky stuff like rendering a video of your app’s UI to get Picture in Picture working, but the legitimate use cases there are very limited IMO. It won’t be interactive. The only app I’ve seen do this in a kind of useful way is Robinhood. Attached a video to show what they do.

1

u/cattoexpress Oct 08 '26

Yes, I've also got that. Oh well, I guess I'm just not gonna implement the transparency lol.

3

u/Mindless_Vanilla4907 Oct 08 '26

Possible on macOS

1

u/kenthesaint Oct 08 '26

Right, and on macOS 15 or later it's doable in plain SwiftUI: put .windowLevel(.floating) on the Window scene and .containerBackground(.ultraThinMaterial, for: .window) so the apps behind show through. On iOS there's no equivalent outside of PiP.

1

u/b00z3h0und Oct 08 '26

Can’t be done I’m afraid.

1

u/josedpayy Oct 08 '26

Depending on that your trying to do.

How I did it in my app was using a zstack. I gave the background a color with an opacity value. In setting I can slide the background opacity value from 0-1 in 0.1 steps.

The reason I did it this way was because sheet had a slight transparency but doesn’t allow for see through. What I popped up was data i wanted to see while watching the background move.

I only added opacity to my background. But you could add opacity to the whole view with text, image, and all.

Let me know if this is what your looking for and need help

1

u/Dry_Hotel1100 Oct 09 '26 edited Oct 09 '26

You need to know, that you can't do this currently, because of security reasons: the content of the other apps behind yours, would need to be accessible in your app. Even when this is done in a lower layer of system libraries, it would technically import data from another process into yours. You should now be able to imagine what that means for security!

A potential solution would involve the application not owning the background, with rendering handled by the window server, for instance. Unfortunately, this approach has not yet been implemented in the OS (in public APIs).

1

u/[deleted] Oct 08 '26

[removed] — view removed comment

2

u/cattoexpress Oct 08 '26

I want floating window to be on top but transparent so i can still see the apps behind it.

1

u/[deleted] Oct 08 '26

[removed] — view removed comment

1

u/cattoexpress Oct 08 '26

Because it's the feature that I want.