Open Christopher-A opened 7 months ago
Hey there, Christopher! IIRC for that tweet I made a custom implementation of a scrolling effect because, yes, UIKit-backed views don't work with Apple's SwiftUI shaders API currently, and ScrollView is one of those.
I guess I could file a radar for this given that scrolling is one of the best instances where this effect can be truly harnessed.
Ah, makes sense. Thanks for the reply!
Actually, I wonder if this is possible for ScrollViews with just a bit of hackery:
This should essentially deliver the effect in your earlier demo with the content blurring out as it is scrolled off the screen.
I got a proof of concept working by applying the contentOffset
to the position
in mapRadius()
... but the performance is horrendous, even returning 0 for any position outside of the visible bounds.
Actually, I wonder if this is possible for ScrollViews with just a bit of hackery:
- Apply a GeometryReader to a background of a the ScrollView's content.
- Use a preference to map the ContentView's GeometryProxy.frame.origin (in the ScrollViews coordinate space) to a State variable, to essentially get the contentOffset.
- Pass the contentOffset to the shader to offset the blur, so it appears fixed in the ScrollView as the content scrolls.
This should essentially deliver the effect in your earlier demo with the content blurring out as it is scrolled off the screen.
That's really smart, but as you said, it's not really performant. Unfortunately (and possibly due to the UIKit backing of it), state updates within ScrollViews aren't handled well.
Filed a radar for this (FB13604715). Let's see how things go.
Aww, I was sad when my ScrollView turned black. I want to use gradial blur as a background for my TabView bar, which is on top of a ScrollView... let's hope this gets fixed!
From one of your older tweets (https://x.com/joogps/status/1667240291869270032?s=20), it looked like you were able to achieve this effect on content contained in a ScrollView. Is this supported with Glur?