Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The best way to implement drawing features like Keynote

I'm trying to make a little iPad tool's for drawing simple geometrical objects (rect, rounded rect, ellipse, star, ...). My goal is to make something very close to Keynote (drawing feature), i.e. let the user add a rect (for instance), resizing it and moving it. I want too the user can select many objects and move them together.

I've thought about at least 3 differents ways to do that :

  • Extends UIView for each object type, a class for Rect, another for Ellipse, ... With custom drawing method. Then add this view as subview of the global view.
  • Extends CALayer for each object type, a class for Rect, another for Ellipse, ... With custom drawing method. Then add this layer as sublayer of the global view layer's.
  • Extends NSObject for each object type, a class for Rect, another for Ellipse, ... With just a drawing method which will get as argument a CGContext and a Rect and draw directly the form in it. Those methods will be called by the drawing method of the global view.

I'm aware that the two first ways come with functions to detect touch on each object, to add easily shadows,... but I'm afraid that they are a little too heavy ? That's why I thought about the last way, which it seems to be straight forward.

Which way will be the more efficient ??? Or maybe I didn't thought another way ?

Any help will be appreciated ;-)

Thanks.

like image 557
Johann Fradj Avatar asked May 10 '10 07:05

Johann Fradj


1 Answers

I'd use the UIKit classes to do your drawing, then profile and optimise your code from there.

Apple/iPad info: link text

like image 112
petert Avatar answered Nov 07 '22 21:11

petert