Visual Effect Material (Vibrancy) 视觉效果材质(Vibrancy) macos

Vibrancy on

The wallpaper bleeds through the frosted material.

标本可交互 —— 点点看。Specimen is live — try it.

Anatomy — every part, named解剖 —— 每个部件的名字

  1. 1 Material layer材质层 NSVisualEffectView.Material

    “The frosted glass background behind the panel” is the material layer.

    “面板背后的毛玻璃背景”就是材质层。

    Prompt fragmentPrompt 片段

    an NSVisualEffectView.Material layer providing the adaptive translucent background for the surface

    一个 NSVisualEffectView.Material 材质层,为界面提供自适应的半透明背景

  2. 2 Vibrant foregroundVibrancy 前景 NSVisualEffectView.allowsVibrancy

    “The text and icons that adapt against the glass” are the vibrant foreground.

    “在玻璃背景上自适应的文字和图标”就是 vibrancy 前景。

    Prompt fragmentPrompt 片段

    the NSVisualEffectView.allowsVibrancy foreground treatment that keeps controls legible over the material

    NSVisualEffectView.allowsVibrancy 前景处理,让控件在材质上保持清晰可读

Prompt — paste into your agentPrompt —— 直接粘贴给你的代理

Use an NSVisualEffectView for this Visual Effect Material background (SwiftUI: Material). Choose NSVisualEffectView.Material by semantic purpose and set the appropriate BlendingMode; let standard controls supply vibrancy automatically instead of recreating the effect with a fixed blur and opacity.

用 NSVisualEffectView 实现这个视觉效果材质背景(SwiftUI:Material)。按语义用途选择 NSVisualEffectView.Material,并设置合适的 BlendingMode;让标准控件自动提供 vibrancy,不要用固定的模糊和不透明度去重造这个效果。

Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时

Debug my macOS vibrancy (NSVisualEffectView). Rule out: the wrong material for the surface (sidebar, menu, popover, hudWindow are distinct); blendingMode withinWindow when behindWindow was intended so nothing shows through; vibrant text/controls dead because they are not descendants of the effect view; everything going grey when the window deactivates via state followsWindowActiveState. The symptom:

调试我的 macOS vibrancy(NSVisualEffectView)。逐一排除:材质选错了界面类型(sidebar、menu、popover、hudWindow 各不相同);想要 behindWindow 却设成了 withinWindow,导致什么也透不出来;带 vibrancy 的文字和控件失效,因为它们不是效果视图的子视图;state 设为 followsWindowActiveState 导致窗口失活时一切变灰。症状是:

In code代码里叫什么

Framework框架Symbol符号Note说明
AppKit NSVisualEffectView
AppKit NSVisualEffectView.Material
AppKit NSVisualEffectView.BlendingMode
SwiftUI Material

See also相关词条