跳到正文
Skillpedia
移动应用7.4k · #13249

swiftui-liquid-glass

它能做什么

这个技能指导在 SwiftUI 中使用 Apple 的玻璃设计效果,用于构建、改进或审核某项功能。适合采用较新的 Liquid Glass 外观的 iOS 开发者。

适用场景

  • ✓你希望某个 SwiftUI 界面采用 Liquid Glass 风格的时候。
  • ✓你希望审核某项现有功能是否正确使用了玻璃效果的时候。
  • ✓你需要在玻璃效果之外,兼顾较旧 iOS 版本的时候。

技能链接

https://github.com/steipete/agent-scripts/blob/main/skills/swiftui-liquid-glass/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/steipete/agent-scripts/blob/main/skills/swiftui-liquid-glass/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请把这个 SwiftUI 工具栏更新为 Liquid Glass 样式,并为较早的 iOS 版本提供备用方案。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会使用原生的玻璃效果和容器,在有用的地方为可点击元素添加效果,并在 iOS 26 及更新版本上检查可用性,同时为旧版本提供合理的备用方案。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

SwiftUI Liquid Glass

Attribution: copied from @Dimillian’s Dimillian/Skills (2025-12-31).

Overview

Use this skill to build or review SwiftUI features that fully align with the iOS 26+ Liquid Glass API. Prioritize native APIs (glassEffect, GlassEffectContainer, glass button styles) and Apple design guidance. Keep usage consistent, interactive where needed, and performance aware.

Workflow Decision Tree

Choose the path that matches the request:

1) Review an existing feature

  • Inspect where Liquid Glass should be used and where it should not.
  • Verify correct modifier order, shape usage, and container placement.
  • Check for iOS 26+ availability handling and sensible fallbacks.

2) Improve a feature using Liquid Glass

  • Identify target components for glass treatment (surfaces, chips, buttons, cards).
  • Refactor to use GlassEffectContainer where multiple glass elements appear.
  • Introduce interactive glass only for tappable or focusable elements.

3) Implement a new feature using Liquid Glass

  • Design the glass surfaces and interactions first (shape, prominence, grouping).
  • Add glass modifiers after layout/appearance modifiers.
  • Add morphing transitions only when the view hierarchy changes with animation.

Core Guidelines

  • Prefer native Liquid Glass APIs over custom blurs.
  • Use GlassEffectContainer when multiple glass elements coexist.
  • Apply .glassEffect(...) after layout and visual modifiers.
  • Use .interactive() for elements that respond to touch/pointer.
  • Keep shapes consistent across related elements for a cohesive look.
  • Gate with #available(iOS 26, *) and provide a non-glass fallback.

Review Checklist

  • Availability: #available(iOS 26, *) present with fallback UI.
  • Composition: Multiple glass views wrapped in GlassEffectContainer.
  • Modifier order: glassEffect applied after layout/appearance modifiers.
  • Interactivity: interactive() only where user interaction exists.
  • Transitions: glassEffectID used with @Namespace for morphing.
  • Consistency: Shapes, tinting, and spacing align across the feature.

Implementation Checklist

  • Define target elements and desired glass prominence.
  • Wrap grouped glass elements in GlassEffectContainer and tune spacing.
  • Use .glassEffect(.regular.tint(...).interactive(), in: .rect(cornerRadius: ...)) as needed.
  • Use .buttonStyle(.glass) / .buttonStyle(.glassProminent) for actions.
  • Add morphing transitions with glassEffectID when hierarchy changes.
  • Provide fallback materials and visuals for earlier iOS versions.

Quick Snippets

Use these patterns directly and tailor shapes/tints/spacing.

if #available(iOS 26, *) {
    Text("Hello")
        .padding()
        .glassEffect(.regular.interactive(), in: .rect(cornerRadius: 16))
} else {
    Text("Hello")
        .padding()
        .background(.ultraThinMaterial, in: RoundedRectangle(cornerRadius: 16))
}
GlassEffectContainer(spacing: 24) {
    HStack(spacing: 24) {
        Image(systemName: "scribble.variable")
            .frame(width: 72, height: 72)
            .font(.system(size: 32))
            .glassEffect()
        Image(systemName: "eraser.fill")
            .frame(width: 72, height: 72)
            .font(.system(size: 32))
            .glassEffect()
    }
}
Button("Confirm") { }
    .buttonStyle(.glassProminent)

Resources

  • Reference guide: references/liquid-glass.md
  • Prefer Apple docs for up-to-date API details.
常见问题

是否应改用自定义模糊效果?

不应该。技能建议优先使用原生的 Liquid Glass API,而不是自定义模糊。

它面向哪些设备?

iOS 26 及更新版本,并为更早的版本提供备用处理。

玻璃效果应用在哪里?

在布局和外观修饰符之后应用;当有多个效果出现时,将它们放在一个容器中分组。

详情

作者的原始描述

SwiftUI Liquid Glass: implement, adopt, refactor, review correctness/perf/design.

repo: steipete/agent-scripts

热度

GitHub 星标
7.4k
排名
#13249
许可证
MIT
更新时间
2026/10/30

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能