I would like to develop an app when the user can draw lines... but I do not want to draw straight lines but want to show the line as the users draws it. When the user gets from point A to B I would like to straighten the line (if the users wants this).
To be able to do this I want to change my view into a grid starting at 0,0 (top left) and ending at 320,480 (for iPhone) and 768,1024 (for iPad) (bottom right).
For this question I have point A at 10,10 and point B at 100,100.
My question:
- How do I create this grid?
- How do I create these points?
- How do I draw this line without straightening it?
- How do I draw the straighten line?
My problem is that I am familiar with creating "normal" UI apps. I am not familiar with Open-GL ect.
I hope someone can help me with this.
Best regards,
Paul Peelen
You can drag straight line when user drag it based on starting and ending point draw a line using UIBezierPath and CAShapeLayer:
Hope this will help to achieve your goal.
You subclass your
UIView
and override the- (void)drawRect:(CGRect)rect
method.In there you grab a graphics context:
And you use that to make Core Graphics calls, like:
Look up the Quartz 2D Programming Guide for all the details.