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。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 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
GlassEffectContainerwhere 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
GlassEffectContainerwhen 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:
glassEffectapplied after layout/appearance modifiers. - Interactivity:
interactive()only where user interaction exists. - Transitions:
glassEffectIDused with@Namespacefor morphing. - Consistency: Shapes, tinting, and spacing align across the feature.
Implementation Checklist
- Define target elements and desired glass prominence.
- Wrap grouped glass elements in
GlassEffectContainerand tune spacing. - Use
.glassEffect(.regular.tint(...).interactive(), in: .rect(cornerRadius: ...))as needed. - Use
.buttonStyle(.glass)/.buttonStyle(.glassProminent)for actions. - Add morphing transitions with
glassEffectIDwhen 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
评论
- …
同一仓库的更多技能
beeper
7.4k帮你的智能体搜索本地 Beeper 聊天记录,找到消息,并判断模糊线索指的是哪个聊天或联系人。
cloudflare-registrar
7.4k帮你的智能体查询 Cloudflare Registrar 的域名价格和可用性,并在确认后注册或列出域名。
codexbar
7.4k帮你的智能体查看你在 Codex、Claude、Kimi 等 AI 服务中还剩多少用量,包括限额、额度和重置时间。
create-cli
7.4k帮你的智能体设计命令行工具的命令、参数、帮助文本、输出和错误提示,让人和脚本都能顺利使用。