Skip to content

Commit f82ad7a

Browse files
committed
Update VisualEffectView.swift
1 parent d32bc43 commit f82ad7a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Sources/VisualEffectView/VisualEffectView.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,19 @@ private extension VisualEffectView {
237237
}
238238
}
239239

240+
/// Creates UIGlassEffect using runtime reflection to avoid compile-time SDK dependency
241+
func createGlassEffect(style: GlassStyle) -> UIVisualEffect? {
242+
// Check if UIGlassEffect exists at runtime (iOS 26+)
243+
guard let glassEffectClass = NSClassFromString("UIGlassEffect") as? NSObject.Type else {
244+
return nil
245+
}
246+
247+
// Create the effect using KVC to avoid compile-time type checking
248+
let glassEffect = glassEffectClass.init()
249+
glassEffect.setValue(style.rawValue, forKey: "style")
250+
return glassEffect as? UIVisualEffect
251+
}
252+
240253
func reapplyCustomSnapshot() {
241254
// Apply in a safe order; these call into the existing custom pipeline
242255
self.scale = customSnapshot.scale

0 commit comments

Comments
 (0)