How do I apply .glassEffectID("eraser", in: namespace) in uikit

Asked on 2026-03-05

1 search

To apply the .glassEffectID("eraser", in: namespace) in UIKit, you would need to use the new Liquid Glass design system introduced by Apple. While the specific method .glassEffectID("eraser", in: namespace) is not directly applicable in UIKit, you can achieve similar effects using the new UI Visual Effect View and the Liquid Glass material.

Here's a general approach based on the information from the WWDC sessions:

  1. Create a UI Visual Effect View: This is the starting point for adding glass effects in UIKit. You can configure this view to use the new Liquid Glass material.

  2. Configure the Glass Effect: Use the new APIs to customize the appearance of the glass, such as its shape and interaction properties. You can animate the glass effect to appear or disappear using a special materialized animation.

  3. Add Content: Use the content view of the UI Visual Effect View to add labels, images, or other UI elements. These elements will automatically adapt to the glass effect, becoming vibrant based on their text color.

  4. Interactive Elements: If you want interactive elements like buttons to react to user interactions, set isInteractive to true on the glass effect.

For more detailed guidance, you can refer to the session Build a UIKit app with the new design (19:15) which covers custom elements and how to integrate them with the new design system.

How do I apply .glassEffectID("eraser", in: namespace) in uikit | Ask WWDC