iPhone 核心图形动画

发布于 2024-12-29 09:39:59 字数 272 浏览 2 评论 0原文

是否可以在 UIView 的 drawRect 方法中使用核心图形对您绘制的内容进行动画处理?

举例来说,我通过抚摸路径创建了一条锯齿线。如果我想要为该路径中单个点的位置等内容设置动画该怎么办?如果我的UIView具有用于绘制我的点的属性animatedPointX和animatedPointY,我可以通过更改这些属性来以某种方式为我的锯齿线设置动画吗?核心显卡可以实现这样的功能吗?

我发现的每个动画示例和教程都涉及对整个视图进行动画处理。我似乎找不到任何有关动画绘图/图层的自定义属性的信息。

Is it possible to animate something that you have drawn using core graphics in a UIView's drawRect method?

Say for example I have created a zigzag line by stroking a path. What if I want to animate something like the position of an individual point in that path? If my UIView has the properties animatedPointX and animatedPointY which are used to draw my point, can I somehow animate my zigzag line by changing these properties? Is something like this possible with Core Graphics?

Every animation example and tutorial I have found deals with animating an entire view as a whole. I cant seem to find anything about animating custom properties of your drawing/layer.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柠檬色的秋千 2025-01-05 09:39:59

如果您想对在drawRect:中绘制的图形进行动画处理,则需要定期更新控制绘制内容的变量并将setNeedsDisplay发送到视图。

Apple 建议使用 CADisplayLink对象定期通知自己是时候更新和重画了。

您可以在 pARk 示例应用ARView.m 文件。

If you want to animate the graphics that you draw in drawRect:, you need to periodically update the variables that control what you draw and send setNeedsDisplay to the view.

Apple recommends using a CADisplayLink object to periodically notify yourself that it's time to update and redraw.

You can see an example of the use of CADisplayLink to trigger the update and setNeedsDisplay in the ARView.m file of the pARk sample app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文