-
Notifications
You must be signed in to change notification settings - Fork 24.7k
feat: iOS filter blur #52028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: iOS filter blur #52028
Conversation
CAFilter is a private API, by shipping this in React Native you'd put every app at risk of app store rejection. |
CAFilter is something we wanted to use, but we really don’t want to add it as an API that folks could rely on, then be forced to take it back later if Apple doesn’t approve. Given their history, that’s not unlikely. A solution I’ve been curious about though, is that SwiftUI exposes a public filters API that uses this under the hood. There are libraries that have sandwiched SwiftUI views inside of RN’s UIKit hierarchy too. https://github.com/andrew-levy/swiftui-react-native/blob/master/ios/VStack/VStackExpoView.swift I imagine it might be easier to compose a “FilterView” or the like, which sandwiches in the SwiftUI view, but I’ve been curious about this as a mechanism to implement the normal CSS filters API, with some clever view hierarchy management. |
@NickGerleman i haven't done much digging on the SwiftUI approach yet, looks interesting, will try some stuff. I also found a library that accesses |
Summary:
This PR is controversial since it uses CAFilter API to achieve the desired
filter: blur()
effect. But I thought to open the PR, to keep it open for discussion. Currently, this API is the simplest and most performant way to achieve the effect.Changelog:
[IOS] [ADDED] - Blur filter
Test Plan:
Run RNTester blur example, which is enabled in the PR. Set the
hotdog
image's overflow tovisible
or else blur will clip to bounds for image.Aside:
I have seen some competing frameworks using this property in the wild. So I wanted to open the discussion if we can do the same in RN.
CIFilter
option does not seem feasible for generic views apart from images. MaybeMetal
can help? I haven't done much digging there.