iPhone 核心图形动画
是否可以在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想对在
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 sendsetNeedsDisplay
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 andsetNeedsDisplay
in theARView.m
file of thepARk
sample app.