core-animation

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Core Animation Reference

Core Animation 参考文档

Search these docs to answer questions about Core Animation (the QuartzCore framework). Use this skill when working directly with
CALayer
, layer-backed UIKit/AppKit views, explicit keyframe or spring animations on layer properties, particle systems, or per-frame callbacks via
CADisplayLink
.
For SwiftUI's declarative animation API (
withAnimation
,
Animation
,
.animation(_:value:)
, transitions), use
guide-swiftui-animations
instead. For SwiftUI immediate-mode drawing, use
swiftui/canvas.md
and
swiftui/graphicscontext.md
.
搜索这些文档以获取关于 Core Animation(QuartzCore 框架)的问题解答。当你直接使用
CALayer
、基于图层的 UIKit/AppKit 视图、图层属性的显式关键帧或弹性动画、粒子系统,或通过
CADisplayLink
实现逐帧回调时,可以使用此技能。
对于 SwiftUI 的声明式动画 API(
withAnimation
Animation
.animation(_:value:)
、转场效果),请改用
guide-swiftui-animations
。对于 SwiftUI 即时模式绘图,请使用
swiftui/canvas.md
swiftui/graphicscontext.md

Return Format

返回格式

Always include:
  1. Summary — answer the question concisely.
  2. File paths — list relevant files for full details, e.g.:
    • calayer.md
      for layer geometry, contents, hierarchy
    • cabasicanimation.md
      for animating a single property between two values
    • catransaction.md
      for batching, disabling implicit animations, or changing default duration
请始终包含以下内容:
  1. 摘要 — 简洁回答问题。
  2. 文件路径 — 列出相关文件以获取详细信息,例如:
    • calayer.md
      :图层几何结构、内容、层级
    • cabasicanimation.md
      :在两个值之间动画单个属性
    • catransaction.md
      :批量处理、禁用隐式动画或修改默认时长

Files

文件

FileContent
core-animation-index.md
Full QuartzCore framework index — layer basics, animation classes, transactions, layer subclasses
calayer.md
CALayer
— the root layer class: geometry, contents, hierarchy, layout, animations
caanimation.md
CAAnimation
— abstract base class for all Core Animation animation types
capropertyanimation.md
CAPropertyAnimation
— abstract subclass animating a single layer property
cabasicanimation.md
CABasicAnimation
— interpolate a layer property between two values
cakeyframeanimation.md
CAKeyframeAnimation
— animate a property through a sequence of keyframes
caspringanimation.md
CASpringAnimation
— spring-based interpolation with mass, stiffness, damping
caanimationgroup.md
CAAnimationGroup
— run multiple animations together with a shared duration
catransition.md
CATransition
— fade, push, reveal, and move-in transitions between layer states
camediatiming.md
CAMediaTiming
— protocol shared by layers and animations (beginTime, duration, repeat, speed)
catransaction.md
CATransaction
— batch property changes, disable implicit animations, set default duration/timing
catransform3d.md
CATransform3D
— 4×4 matrix used by
CALayer.transform
for 3D transforms
cashapelayer.md
CAShapeLayer
— vector-shape layer driven by a
CGPath
(stroke, fill, line dash)
cagradientlayer.md
CAGradientLayer
— axial, radial, and conic gradient layers
caemitterlayer.md
CAEmitterLayer
— particle emitter layer (fire, smoke, confetti, sparkles)
caemittercell.md
CAEmitterCell
— individual particle definition used by
CAEmitterLayer
careplicatorlayer.md
CAReplicatorLayer
— replicate a sublayer with offsets and transforms
cametallayer.md
CAMetalLayer
— layer backed by a Metal drawable for GPU-rendered content
catextlayer.md
CATextLayer
— layer that renders plain or attributed text
catiledlayer.md
CATiledLayer
— tile-based asynchronous content rendering for large or zoomable layers
cadisplaylink.md
CADisplayLink
— timer synchronized to the display's refresh rate
文件内容
core-animation-index.md
完整的 QuartzCore 框架索引 — 图层基础、动画类、事务、图层子类
calayer.md
CALayer
— 根图层类:几何结构、内容、层级、布局、动画
caanimation.md
CAAnimation
— 所有 Core Animation 动画类型的抽象基类
capropertyanimation.md
CAPropertyAnimation
— 动画单个图层属性的抽象子类
cabasicanimation.md
CABasicAnimation
— 在两个值之间插值图层属性
cakeyframeanimation.md
CAKeyframeAnimation
— 通过一系列关键帧动画属性
caspringanimation.md
CASpringAnimation
— 基于弹性的插值,包含质量、刚度、阻尼参数
caanimationgroup.md
CAAnimationGroup
— 以共享时长同时运行多个动画
catransition.md
CATransition
— 图层状态之间的淡入、推入、显示和移入转场效果
camediatiming.md
CAMediaTiming
— 图层和动画共享的协议(开始时间、时长、重复次数、速度)
catransaction.md
CATransaction
— 批量属性更改、禁用隐式动画、设置默认时长/时序
catransform3d.md
CATransform3D
CALayer.transform
使用的 4×4 矩阵,用于 3D 变换
cashapelayer.md
CAShapeLayer
— 由
CGPath
驱动的矢量图形图层(描边、填充、虚线)
cagradientlayer.md
CAGradientLayer
— 轴向、径向和圆锥渐变图层
caemitterlayer.md
CAEmitterLayer
— 粒子发射器图层(火焰、烟雾、彩纸、闪光效果)
caemittercell.md
CAEmitterCell
CAEmitterLayer
使用的单个粒子定义
careplicatorlayer.md
CAReplicatorLayer
— 通过偏移和变换复制子图层
cametallayer.md
CAMetalLayer
— 由 Metal 可绘制对象支持的图层,用于 GPU 渲染内容
catextlayer.md
CATextLayer
— 渲染普通或富文本的图层
catiledlayer.md
CATiledLayer
— 基于瓦片的异步内容渲染,适用于大型或可缩放图层
cadisplaylink.md
CADisplayLink
— 与显示器刷新率同步的计时器

When to Reach for Core Animation

何时使用 Core Animation

  • You need to animate a layer property SwiftUI/UIKit doesn't expose declaratively (e.g.,
    CAGradientLayer.colors
    ,
    CAShapeLayer.strokeEnd
    ,
    CAEmitterLayer.birthRate
    ).
  • You need explicit keyframe or spring control with timing functions (
    CAMediaTimingFunction
    ) per segment.
  • You want to batch implicit animations off (
    CATransaction.setDisableActions(true)
    ).
  • You need a
    CADisplayLink
    per-frame callback (custom drawing loops, scrubbing, physics).
  • You're rendering thousands of particles with
    CAEmitterLayer
    or replicating sublayers with
    CAReplicatorLayer
    .
If your problem fits inside
withAnimation { ... }
in SwiftUI or
UIView.animate { ... }
in UIKit, prefer those — Core Animation sits underneath both and is rarely the right starting point in 2026-era code.
  • 你需要动画化 SwiftUI/UIKit 未以声明方式暴露的图层属性(例如
    CAGradientLayer.colors
    CAShapeLayer.strokeEnd
    CAEmitterLayer.birthRate
    )。
  • 你需要对每个片段使用时序函数(
    CAMediaTimingFunction
    )进行显式关键帧或弹性控制。
  • 你想要批量关闭隐式动画(
    CATransaction.setDisableActions(true)
    )。
  • 你需要通过
    CADisplayLink
    实现逐帧回调(自定义绘图循环、 scrubbing、物理效果)。
  • 你正在使用
    CAEmitterLayer
    渲染数千个粒子,或使用
    CAReplicatorLayer
    复制子图层。
如果你的问题可以通过 SwiftUI 中的
withAnimation { ... }
或 UIKit 中的
UIView.animate { ... }
解决,请优先使用这些方法——Core Animation 是两者的底层实现,在 2026 年的代码中很少是正确的起点。

Fetching More Docs

获取更多文档

  1. Search this skill's local
    .md
    files first.
  2. If the topic is not here, check the other installed Apple skills, then grep their local files.
  3. If no installed skill has the page, the QuartzCore path on Apple's site is
    /documentation/quartzcore/<symbol>
    — fetch via the
    sosumi.ai
    Markdown mirror (e.g.
    https://sosumi.ai/documentation/quartzcore/camediatimingfunction
    ) or by running
    pnpm fetch-doc
    against the apple-skills tooling.
  1. 首先搜索此技能的本地
    .md
    文件。
  2. 如果此处没有相关主题,请检查其他已安装的 Apple 技能,然后搜索它们的本地文件。
  3. 如果没有已安装的技能包含该页面,Apple 网站上的 QuartzCore 路径为
    /documentation/quartzcore/<symbol>
    — 可通过
    sosumi.ai
    Markdown 镜像(例如
    https://sosumi.ai/documentation/quartzcore/camediatimingfunction
    )或通过
    pnpm fetch-doc
    命令调用 apple-skills 工具来获取。