Communitygithub.com

液态玻璃设计系统 (iOS 26)

iOS 26 液态玻璃设计系统——为 SwiftUI、UIKit 和 WidgetKit 提供动态玻璃材质,支持模糊、反射和交互变形效果。适用于构建 iOS 26 液态玻璃界面的开发场景。

液态玻璃设计系统 (iOS 26) 是什么?

这是一个专为 Apple iOS 26 液态玻璃设计语言打造的 AI Agent 技能,覆盖 SwiftUI、UIKit 和 WidgetKit 三大平台。开发者可通过 `glassEffect()`、`UIGlassEffect` 等 API 快速实现动态玻璃材质,包括背景模糊、颜色与光线反射、触摸和指针交互反应等功能。核心设计强调性能优化:多个玻璃视图需包裹在 `GlassEffectContainer` 或 `UIGlassContainerEffect` 中,以支持变形过渡和合并效果;`@Namespace` 与 `glassEffectID` 配合实现平滑的视图层级变换动画。此外,技能还提供了 WidgetKit 的着色渲染模式适配、滚动边缘效果、工具栏集成等专用模式。同时列出了最佳实践(如始终使用容器、测试明暗模式)和应避免的反模式(如单独使用多个玻璃效果、忘记裁剪)。该技能特别适合需要升级 iOS 26 设计语言的开发者、实现玻璃风格控件或创建美观 widget 的场景。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/liquid-glass-design

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

液态玻璃设计系统 (iOS 26) 是做什么的?

实现 Apple 液态玻璃的模式——一种动态材质,能模糊其背后的内容,反射周围内容的颜色和光线,并对触摸和指针交互做出反应。覆盖 SwiftUI、UIKit 和 WidgetKit 集成。

何时激活

  • 为 iOS 26+ 构建或更新应用,采用新设计语言
  • 实现玻璃风格的按钮、卡片、工具栏或容器
  • 在玻璃元素之间创建变形过渡
  • 为 widget 应用液态玻璃效果
  • 将现有的模糊/材质效果迁移到新的液态玻璃 API

核心模式 — SwiftUI

基本玻璃效果

为任何视图添加液态玻璃的最简单方式:

Text("Hello, World!")
    .font(.title)
    .padding()
    .glassEffect()  // 默认:常规变体,胶囊形状

自定义形状和色调

Text("Hello, World!")
    .font(.title)
    .padding()
    .glassEffect(.regular.tint(.orange).interactive(), in: .rect(cornerRadius: 16.0))

关键自定义选项:

  • .regular — 标准玻璃效果
  • .tint(Color) — 添加颜色色调以增强突出度
  • .interactive() — 对触摸和指针交互做出反应
  • 形状:.capsule(默认)、.rect(cornerRadius:)、.circle

玻璃按钮样式

Button("点击我") { /* 操作 */ }
    .buttonStyle(.glass)

Button("重要") { /* 操作 */ }
    .buttonStyle(.glassProminent)

用于多个元素的 GlassEffectContainer

始终将多个玻璃视图包裹在容器中,以获得更好的性能和变形效果:

GlassEffectContainer(spacing: 40.0) {
    HStack(spacing: 40.0) {
        Image(systemName: "scribble.variable")
            .frame(width: 80.0, height: 80.0)
            .font(.system(size: 36))
            .glassEffect()

        Image(systemName: "eraser.fill")
            .frame(width: 80.0, height: 80.0)
            .font(.system(size: 36))
            .glassEffect()
    }
}

spacing 参数控制合并距离——元素越近,它们的玻璃形状越容易融合。

合并玻璃效果

使用 glassEffectUnion 将多个视图合并为单个玻璃形状:

@Namespace private var namespace

GlassEffectContainer(spacing: 20.0) {
    HStack(spacing: 20.0) {
        ForEach(symbolSet.indices, id: \.self) { item in
            Image(systemName: symbolSet[item])
                .frame(width: 80.0, height: 80.0)
                .glassEffect()
                .glassEffectUnion(id: item < 2 ? "group1" : "group2", namespace: namespace)
        }
    }
}

变形过渡

在玻璃元素出现/消失时创建流畅的变形效果:

@State private var isExpanded = false
@Namespace private var namespace

GlassEffectContainer(spacing: 40.0) {
    HStack(spacing: 40.0) {
        Image(systemName: "scribble.variable")
            .frame(width: 80.0, height: 80.0)
            .glassEffect()
            .glassEffectID("pencil", in: namespace)

        if isExpanded {
            Image(systemName: "eraser.fill")
                .frame(width: 80.0, height: 80.0)
                .glassEffect()
                .glassEffectID("eraser", in: namespace)
        }
    }
}

Button("切换") {
    withAnimation { isExpanded.toggle() }
}
.buttonStyle(.glass)

扩展水平滚动到侧边栏下方

要让水平滚动内容延伸到侧边栏或检查器下方,请确保 ScrollView 内容到达容器的前导/尾随边缘。当布局延伸到边缘时,系统会自动处理侧边栏下方的滚动行为——无需额外的修饰符。

核心模式 — UIKit

基本的 UIGlassEffect

let glassEffect = UIGlassEffect()
glassEffect.tintColor = UIColor.systemBlue.withAlphaComponent(0.3)
glassEffect.isInteractive = true

let visualEffectView = UIVisualEffectView(effect: glassEffect)
visualEffectView.translatesAutoresizingMaskIntoConstraints = false
visualEffectView.layer.cornerRadius = 20
visualEffectView.clipsToBounds = true

view.addSubview(visualEffectView)
NSLayoutConstraint.activate([
    visualEffectView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
    visualEffectView.centerYAnchor.constraint(equalTo: view.centerYAnchor),
    visualEffectView.widthAnchor.constraint(equalToConstant: 200),
    visualEffectView.heightAnchor.constraint(equalToConstant: 120)
])

// 向 contentView 添加内容
let label = UILabel()
label.text = "液态玻璃"
label.translatesAutoresizingMaskIntoConstraints = false
visualEffectView.contentView.addSubview(label)
NSLayoutConstraint.activate([
    label.centerXAnchor.constraint(equalTo: visualEffectView.contentView.centerXAnchor),
    label.centerYAnchor.constraint(equalTo: visualEffectView.contentView.centerYAnchor)
])

用于多个元素的 UIGlassContainerEffect

let containerEffect = UIGlassContainerEffect()
containerEffect.spacing = 40.0

let containerView = UIVisualEffectView(effect: containerEffect)

let firstGlass = UIVisualEffectView(effect: UIGlassEffect())
let secondGlass = UIVisualEffectView(effect: UIGlassEffect())

containerView.contentView.addSubview(firstGlass)
containerView.contentView.addSubview(secondGlass)

滚动边缘效果

scrollView.topEdgeEffect.style = .automatic
scrollView.bottomEdgeEffect.style = .hard
scrollView.leftEdgeEffect.isHidden = true

工具栏玻璃集成

let favoriteButton = UIBarButtonItem(image: UIImage(systemName: "heart"), style: .plain, target: self, action: #selector(favoriteAction))
favoriteButton.hidesSharedBackground = true  // 选择退出共享玻璃背景

核心模式 — WidgetKit

渲染模式检测

struct MyWidgetView: View {
    @Environment(\.widgetRenderingMode) var renderingMode

    var body: some View {
        if renderingMode == .accented {
            // 着色模式:白色着色,主题玻璃背景
        } else {
            // 全彩色模式:标准外观
        }
    }
}

用于视觉层级的强调组

HStack {
    VStack(alignment: .leading) {
        Text("标题")
            .widgetAccentable()  // 强调组
        Text("副标题")
            // 主要组(默认)
    }
    Image(systemName: "star.fill")
        .widgetAccentable()  // 强调组
}

着色模式中的图像渲染

Image("myImage")
    .widgetAccentedRenderingMode(.monochrome)

容器背景

VStack { /* 内容 */ }
    .containerBackground(for: .widget) {
        Color.blue.opacity(0.2)
    }

关键设计决策

决策理由
GlassEffectContainer 包裹性能优化,支持玻璃元素之间的变形
spacing 参数控制合并距离——微调元素需要多近才能融合
@Namespace + glassEffectID在视图层级变化时实现平滑的变形过渡
interactive() 修饰符显式选择触摸/指针反应——并非所有玻璃都应响应
UIKit 中的 UIGlassContainerEffect与 SwiftUI 相同的容器模式以保持一致性
Widget 中的着色渲染模式当用户选择着色主屏幕时,系统应用着色玻璃

最佳实践

  • 始终使用 GlassEffectContainer:对多个同级视图应用玻璃效果时使用——它支持变形并提高渲染性能
  • 在其他外观修饰符之后应用 .glassEffect():在 frame、font、padding 之后
  • 仅在需要响应交互的元素上使用 .interactive():按钮、可切换项
  • 在容器中仔细选择 spacing:控制玻璃效果的合并时机
  • 在更改视图层级时使用 withAnimation:以实现平滑的变形过渡
  • 跨外观测试:浅色模式、深色模式和着色/色调模式
  • 确保无障碍对比度:玻璃上的文本必须保持可读性

应避免的反模式

  • 在未使用 GlassEffectContainer 的情况下,使用多个独立的 .glassEffect() 视图
  • 嵌套过多玻璃效果——会降低性能和视觉清晰度
  • 对所有视图都应用玻璃效果——保留用于交互元素、工具栏和卡片
  • 在 UIKit 中使用圆角时忘记 clipsToBounds = true
  • 忽略 Widget 中的着色渲染模式——会破坏着色主屏幕的外观
  • 在玻璃后面使用不透明背景——会破坏半透明效果

何时使用

  • 使用新的 iOS 26 设计的导航栏、工具栏和标签栏
  • 浮动操作按钮和卡片式容器
  • 需要视觉深度和触摸反馈的交互控件
  • 需要与系统液态玻璃外观集成的 Widget
  • 相关 UI 状态之间的变形过渡

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

相关技能