核心动画还是OpenGL ES? [英] Core Animation or OpenGL ES?

查看:210
本文介绍了核心动画还是OpenGL ES?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要执行以下操作:



点击屏幕,在抽点处绘制3个小指。



我从哪里开始?

解决方案

如上所述,Core Graphics框架可能是你想要的。一个好的方法是将UIView子类化,然后覆盖两个方法 drawRect: touchesEnded:withEvent:



当触摸事件在UIView上结束时,可以将事件最后一次触摸的点传递给 touchesEnded:withEvent:

然后,在你的实现 drawRect:,你将得到存储的最后一个触摸点,并使用对 CGContextAddEllipseInRect 的三次调用绘制三个圆圈,如下所述: Quartz 2D编程指南:路径(注册为Apple需要开发人员)。


I want to do the following:

Tap the screen and draw 3 cricles around the the tapped point. Is it better to do this with Core Animation or OpenGL ES?

Where do I start?

解决方案

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:.

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.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆