I'm trying to make a small iPad tool for drawing simple geometric objects (rectangle, rounded rectangle, ellipse, star, ...). My goal is to do something very close to Keynote (the drawing function), that is, let the user add a rectangle (for example), resize it and move it. I also want the user to be able to select many objects and move them together.
I was thinking of at least 3 different ways to do this:
- Extends UIView for each type of object, class for Rect, another for Ellipse, ... using a custom drawing method. Then add this view as a subview of the global view.
- Extends CALayer for each type of object, class for Rect, another for Ellipse, ... using a custom drawing method. Then add this layer as a sublayer of the global view layer.
- Extends NSObject for each type of object, a class for Rect, another for Ellipse, ... Using just a drawing method, which takes CGContext and Rect as an argument and draws the form directly in it. These methods will be called by drawing a global view.
I know that the first two ways come with functions for detecting the touch of each object, for adding easily shadows ... but I'm afraid that they are too heavy? That is why I thought of the last method, which seems straightforward.
Which way will be more efficient? Or maybe I did not think otherwise?
Any help would be appreciated -)
Thanks.
optimization iphone calayer uiview drawing
Johann Fradj
source share