ios-animation-code-review
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseiOS Animation Code Review
iOS 动画代码审查
Quick Reference
快速参考
| Issue Type | Reference |
|---|---|
| Spring parameters, withAnimation misuse, phase/keyframe bugs | references/swiftui-animation-patterns.md |
| Frame drops, offscreen rendering, main thread blocking | references/performance.md |
| Reduce Motion, VoiceOver, motion sensitivity | references/accessibility.md |
| Transition protocol, matchedGeometryEffect, navigation transitions | references/transitions.md |
| 问题类型 | 参考文档 |
|---|---|
| 弹簧参数、withAnimation 误用、阶段/关键帧错误 | references/swiftui-animation-patterns.md |
| 掉帧、离屏渲染、主线程阻塞 | references/performance.md |
| 减少动态效果、VoiceOver、运动敏感度 | references/accessibility.md |
| Transition 协议、matchedGeometryEffect、导航转场 | references/transitions.md |
Output Format
输出格式
Report each finding as:
[FILE:LINE] ISSUE_TITLEExample:
[AnimatedCard.swift:42] Missing Reduce Motion fallback for spring animationAll details, code suggestions, and rationale follow after the header line.
每个问题报告格式如下:
[文件:行号] 问题标题示例:
[AnimatedCard.swift:42] 弹簧动画缺少减少动态效果的降级方案所有细节、代码建议及原理说明均在标题行之后列出。
Review Checklist
审查清单
- checked — animations have Reduce Motion fallback
@Environment(\.accessibilityReduceMotion) - Animation is not the sole feedback channel — important state changes pair with haptics () or audio
.sensoryFeedback - Custom animation isn't duplicating system-provided motion (standard nav transitions, sheet presentation, SF Symbol effects)
- Animations on frequent interactions are brief and unobtrusive — or absent (system handles it)
- All animations are interruptible — user is never forced to wait for completion before interacting
- Spring animations use /
durationparameters (not raw mass/stiffness/damping unless UIKit/CA)bounce - No deprecated without
.animation()parametervalue: - wraps state changes, not view declarations
withAnimation - IDs are stable and unique within the namespace
matchedGeometryEffect - used when parent geometry animates with child views appearing
geometryGroup() - Looping animations (,
PhaseAnimator) have finite phases or appropriate triggersymbolEffect - No in UIView-backed layers (use UIView.animate instead)
CATransaction.setAnimationDuration() - Interactive animations handle interruption (re-trigger mid-flight doesn't break state)
- Shadow animations provide explicit (avoids per-frame recalculation)
shadowPath - Gesture-driven animations preserve velocity on release for natural completion
- Gesture-driven feedback follows spatial expectations (dismiss direction matches reveal direction)
- No animation of modifier (destroys view identity — use
.id()ortransitioninstead)matchedGeometryEffect
- 已检查 —— 动画具备减少动态效果的降级方案
@Environment(\.accessibilityReduceMotion) - 动画并非唯一反馈渠道 —— 重要状态变更搭配触觉反馈()或音频
.sensoryFeedback - 自定义动画未重复系统提供的动效(标准导航转场、弹窗展示、SF Symbol 效果)
- 频繁交互场景下的动画简洁且不突兀 —— 或直接由系统处理
- 所有动画均可中断 —— 用户无需等待动画完成即可进行交互
- 弹簧动画使用 /
duration参数(除非是 UIKit/CA 场景,否则不使用原始的 mass/stiffness/damping 参数)bounce - 无未指定 参数的废弃
value:用法.animation() - 包裹状态变更逻辑,而非视图声明
withAnimation - 的 ID 在命名空间内稳定且唯一
matchedGeometryEffect - 父级几何动画伴随子视图出现时已使用
geometryGroup() - 循环动画(、
PhaseAnimator)具备有限阶段或合适的触发条件symbolEffect - UIView 托管的图层中未使用 (改用 UIView.animate)
CATransaction.setAnimationDuration() - 交互式动画可处理中断(中途重新触发不会破坏状态)
- 阴影动画提供了明确的 (避免逐帧重新计算)
shadowPath - 手势驱动的动画在释放时保留速度,以实现自然完成效果
- 手势驱动的反馈符合空间预期(关闭方向与展示方向一致)
- 未对 修饰器执行动画(会破坏视图标识 —— 改用
.id()或transition)matchedGeometryEffect
When to Load References
何时加载参考文档
- Incorrect spring setup or scope issues → swiftui-animation-patterns.md
withAnimation - Hitches, dropped frames, or expensive animations in scroll views → performance.md
- Missing Reduce Motion handling or motion accessibility → accessibility.md
- glitches or custom
matchedGeometryEffectbugs → transitions.mdTransition
- 弹簧设置错误或 作用域问题 → swiftui-animation-patterns.md
withAnimation - 卡顿、掉帧或滚动视图中的高开销动画 → performance.md
- 缺少减少动态效果处理或动效可访问性问题 → accessibility.md
- 异常或自定义
matchedGeometryEffect错误 → transitions.mdTransition
Review Questions
审查问题
- Does every animation have a Reduce Motion fallback that preserves the information conveyed? Is animation the only feedback channel, or are haptics/audio supplementing it?
- Is this custom animation necessary, or does the system already provide it (standard transitions, SF Symbol effects, Liquid Glass)?
- Could this animation cause frame drops — is it animating expensive properties (blur, shadow without path, mask) in a list or scroll view?
- Are all animations interruptible? Can the user act without waiting for completion? Does gesture-driven feedback follow spatial expectations?
- Is scoped to the minimal state change needed, or is it wrapping unrelated mutations?
withAnimation - For — are source and destination using the same ID and namespace, and is only one visible at a time?
matchedGeometryEffect
- 每个动画是否都有保留信息传递的减少动态效果降级方案?动画是唯一反馈渠道,还是有触觉/音频作为补充?
- 这个自定义动画是否必要,还是系统已提供对应的动效(标准转场、SF Symbol 效果、Liquid Glass)?
- 该动画是否会导致掉帧 —— 是否在列表或滚动视图中对高开销属性(模糊、无路径的阴影、蒙版)执行动画?
- 所有动画是否均可中断?用户无需等待完成即可操作吗?手势驱动的反馈是否符合空间预期?
- 的作用域是否仅限于所需的最小状态变更,还是包裹了无关的修改操作?
withAnimation - 对于 —— 源端和目标端是否使用相同的 ID 和命名空间,且同一时间仅显示其中一方?
matchedGeometryEffect