Skip to content

UIVisualEffect ​

UIVisualEffect represents a visual effect. It is the common superclass of four effects: UIBlurEffect (blur), UIVibrancyEffect (vibrancy), UIGlassEffect (glass), and UIGlassContainerEffect (glass container).

An effect object displays nothing by itself; it becomes visible only when given to a UIVisualEffectView. UIVisualEffect has no members; its purpose is to serve as a type: the effect view's effect property accepts any kind of effect.

Inheritance: EventTarget → NSObject → UIVisualEffect

Constructor ​

Can't be created with new. Create effects with the factory methods or constructors of the four subclasses:

ClassHow to get one
UIBlurEffectUIBlurEffect.effectWithStyle()
UIVibrancyEffectUIVibrancyEffect.effectForBlurEffect()
UIGlassEffectUIGlassEffect.effectWithStyle()
UIGlassContainerEffectnew UIGlassContainerEffect()

Examples ​

js
/** @param {UIVisualEffectView} view */
function describe(view) {
  const effect = view.effect;
  if (effect === null) return 'no effect';
  if (effect instanceof UIBlurEffect) return 'blur';
  if (effect instanceof UIGlassEffect) return 'glass';
  return 'another effect';
}
console.log(describe(new UIVisualEffectView(UIBlurEffect.effectWithStyle('dark'))));

Result: Prints blur. Checking the kind of effect with instanceof is not verified in the simulator.

Corresponding iOS API ​

UIVisualEffect.

See also ​