核心动画还是 OpenGL ES? [英] Core Animation or OpenGL ES?
问题描述
我想做以下事情:
点击屏幕并在点击的点周围绘制 3 个 cricles.使用 Core Animation 还是 OpenGL ES 会更好吗?
Tap the screen and draw 3 cricles around the the tapped point. Is it better to do this with Core Animation or OpenGL ES?
我从哪里开始?
推荐答案
如前所述,Core Graphics 框架可能是您想要的.一个好的方法是继承 UIView,然后覆盖 drawRect:
和 touchesEnded:withEvent:
这两个方法.
As mentioned, the Core Graphics framework is probably what you want. A good way to go about it would be to subclass UIView, then override the two methods drawRect:
and touchesEnded:withEvent:
.
当 UIView 上的触摸事件结束时,您可以从传递给 touchesEnded:withEvent:
的事件中获取最后一次触摸的点,并将其以某种方式存储在子类 UIView 的实例中.
When a touch event ends on the UIView, you can get the point of the last touch from the event passed to touchesEnded:withEvent:
, and store it somehow in the instance of your subclassed UIView.
然后,在您的 drawRect:
实现中,您将获得存储的最后一个触摸点,并使用对 CGContextAddEllipseInRect
的三个调用在其周围绘制三个圆圈,如前所述此处:Quartz 2D 编程指南:路径(需要注册为 Apple Developer).
Then, in your implementation of drawRect:
, you'll get the stored last touch point, and draw three circles around it using three calls to CGContextAddEllipseInRect
, as discussed here: Quartz 2D Programming Guide: Paths (registration as Apple Developer required).
这篇关于核心动画还是 OpenGL ES?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!