swiftui-iconography-api
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSF Symbols & Iconography API Reference
SF Symbols 与图标API参考
Lifecycle Position
生命周期定位
Phase 3 API Reference — load during implementation when using SF Symbols or custom icons. Dispatched from Phase 2 research table.
autonomous-ui-workflow第三阶段API参考——在使用SF Symbols或自定义图标的实现阶段加载。从第二阶段研究表调度。
autonomous-ui-workflowQuick Reference
快速参考
| API | Purpose |
|---|---|
| System SF Symbol |
| Symbol with 0.0-1.0 value |
| Set rendering mode |
| Add variant (.fill, .circle) |
| Animate symbol |
| Palette colors (implies palette mode) |
| API | 用途 |
|---|---|
| 系统SF Symbol |
| 带有0.0-1.0变量值的Symbol |
| 设置渲染模式 |
| 添加变体(.fill、.circle) |
| 为Symbol添加动画 |
| 调色板颜色(隐含调色板模式) |
Rendering Modes
渲染模式
| Mode | Usage |
|---|---|
| Single color: |
| Layered opacity: |
| Inherent colors: |
| Custom per-layer: |
| 模式 | 用法 |
|---|---|
| 单一颜色: |
| 分层透明度: |
| 固有颜色: |
| 自定义分层颜色: |
Symbol Effects
符号效果
swift
// Indefinite (repeating)
Image(systemName: "bolt.slash.fill").symbolEffect(.pulse)
// Active/inactive
Image(systemName: "wifi").symbolEffect(.pulse, isActive: isConnecting)
// Value-driven
Image(systemName: "bell").symbolEffect(.bounce, value: count)
// As transition
.transition(.symbolEffect(.appear))swift
// Indefinite (repeating)
Image(systemName: "bolt.slash.fill").symbolEffect(.pulse)
// Active/inactive
Image(systemName: "wifi").symbolEffect(.pulse, isActive: isConnecting)
// Value-driven
Image(systemName: "bell").symbolEffect(.bounce, value: count)
// As transition
.transition(.symbolEffect(.appear))Variable Values
变量值
swift
Image(systemName: "chart.bar.fill", variableValue: 0.3) // partial
Image(systemName: "chart.bar.fill", variableValue: 1.0) // fullswift
Image(systemName: "chart.bar.fill", variableValue: 0.3) // partial
Image(systemName: "chart.bar.fill", variableValue: 1.0) // fullWhen to Use Which
场景选择指南
| Need | Use |
|---|---|
| Standard system icon | |
| Icon with accessible label | |
| Icon matching adjacent text weight | |
| Animated symbol feedback | |
| Progress/level indicator | |
| Multi-color system icon | |
| Icon tinted to match theme | |
| Custom app icon | Asset catalog → Symbol Image Set → export from SF Symbols app |
| 需求 | 对应方案 |
|---|---|
| 标准系统图标 | |
| 带无障碍标签的图标 | |
| 图标权重与相邻文本匹配 | 为Image设置 |
| 带动画反馈的符号 | |
| 进度/等级指示器 | |
| 多色系统图标 | |
| 匹配主题色调的图标 | 使用 |
| 自定义应用图标 | 资源目录 → Symbol Image Set → 从SF Symbols应用导出 |
Common Mistakes
常见错误
- without
Image(systemName:)in buttons — no accessibility text for VoiceOverLabel - Mismatched symbol weight with adjacent text — icons look too thin/thick next to text. Match with or
.fontWeight().imageScale() - Using for sizing instead of
.resizable().frame()— breaks alignment with text. Use.font()to match text size.font(.title) - Missing — defaults to monochrome which may not match design intent
.symbolRenderingMode() - Hardcoded symbol names without checking SF Symbols availability — some symbols require iOS 16+ or 17+
Before (incorrect):
swift
Button(action: addFavorite) {
Image(systemName: "star.fill") // no label — VoiceOver reads nothing useful
}After (correct):
swift
Button(action: addFavorite) {
Label("Add to Favorites", systemImage: "star.fill")
}Before (incorrect):
swift
Image(systemName: "heart.fill")
.resizable()
.frame(width: 24, height: 24) // disrupts text baseline alignmentAfter (correct):
swift
Image(systemName: "heart.fill")
.font(.title2) // scales with Dynamic Type and aligns with text- 按钮中使用而非
Image(systemName:)——VoiceOver无法读取有用的无障碍文本Label - 图标权重与相邻文本不匹配——图标在文本旁显得过细或过粗。使用或
.fontWeight()匹配.imageScale() - 使用调整尺寸而非
.resizable().frame()——破坏与文本的基线对齐。使用.font()匹配文本尺寸.font(.title) - 未设置——默认单色模式可能不符合设计意图
.symbolRenderingMode() - 硬编码符号名称而未检查SF Symbols的可用性——部分符号需要iOS 16+或17+
错误写法:
swift
Button(action: addFavorite) {
Image(systemName: "star.fill") // no label — VoiceOver reads nothing useful
}正确写法:
swift
Button(action: addFavorite) {
Label("添加到收藏", systemImage: "star.fill")
}错误写法:
swift
Image(systemName: "heart.fill")
.resizable()
.frame(width: 24, height: 24) // disrupts text baseline alignment正确写法:
swift
Image(systemName: "heart.fill")
.font(.title2) // scales with Dynamic Type and aligns with textChecklist
检查清单
- Buttons and toolbar items use not bare
Label("text", systemImage:)Image - Icon weight matches adjacent text weight
- Icon sizing uses or
.font()not.imageScale().resizable().frame() - Rendering mode explicitly set when multicolor or palette needed
- Symbol availability checked for newer symbols ()
@available
- 按钮和工具栏项使用而非单独的
Label("文本", systemImage:)Image - 图标权重与相邻文本权重匹配
- 图标尺寸使用或
.font()而非.imageScale().resizable().frame() - 当需要多色或调色板模式时,显式设置渲染模式
- 检查新版符号的可用性(使用)
@available
Cross-References
交叉引用
- —
swiftui-colors-apifor symbol tintingforegroundStyle() - — review checklist includes accessibility label checks
swiftui-ui-patterns - — macOS toolbar icon conventions
macos-app-design
- — 用于符号着色的
swiftui-colors-apiforegroundStyle() - — 检查清单包含无障碍标签检查
swiftui-ui-patterns - — macOS工具栏图标规范
macos-app-design