如何使用 Quartz2D 绘制可动画的标尺?
我想用 Quartz2D 画一把简单的尺子的线条,仅供练习。
由于我不知道如何在 iPhone 上以编程方式制作矢量图形,也许有人可以给我指点一个好的入门教程?
I'd like to draw the lines of a simple ruler with Quartz2D, just for practice.
Since I have no idea about doing vector graphics programmatically on the iPhone, maybe someone can point me to a good tutorial to get started?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 Plamen 指出的,Quartz 2D 文档< /a> 值得一读。此外,课程笔记可在线获取(VoodooPad 格式),供我使用iPhone 开发课程,我用整个课程来学习 Quartz 2D 绘图。我创建的 QuartzExamples 示例应用程序显示了一些更高级的绘图概念,但是Apple 的 QuartzDemo 示例是一个更好的起点看看如何做简单的绘图。
作为为标尺绘制刻度的示例,以下是我用来执行类似操作的代码:
其中
currentHeight
是要覆盖的区域的高度,[MyView blackColor]< /code> 只是返回一个表示黑色的 CGColorRef。
As Plamen points out, the Quartz 2D documentation is worth reading. Additionally, the course notes are available online (VoodooPad format) for my iPhone development course, where I devote an entire class to Quartz 2D drawing. The QuartzExamples sample application I created shows some more advanced drawing concepts, but Apple's QuartzDemo sample is a better place to start to see how you can do simple drawing.
As an example of drawing ticks for a ruler, the following is code that I have used to do something similar:
where
currentHeight
is the height of the area to cover, and[MyView blackColor]
simply returns a CGColorRef representing the color black.