views:

451

answers:

3

I need to draw a line with an arrow head. How can i do this using Core graphics. Any help!!!

+3  A: 
  1. Draw a line.
  2. Draw a triangle at the end of it.

Yes, that is, in fact, the only way. (Well, unless somebody has released some source code that does that for you. If not, maybe you'll be the one to do so? ☺)

Peter Hosey
Ok. To draw triangle at the end,one side of my triangle must be perpendicular to my line. How i get that perpendicular line .
diana
Don't worry about that. Draw your triangle in a constant orientation. Use trigonometry to work out the angle of the line, then rotate the current transformation matrix by a corresponding angle before drawing the triangle.
Peter Hosey
You can even draw the triangle only once into a CGMutablePath, with its origin at 0,0, then translate the CTM before rotating it to get the triangle into the correct position. (This is a bit trickier, though.)
Peter Hosey
Ok.Thank u very much..Let me try.
diana
A: 

Rose,

Can you post the code if you have found it?

Thanks

Pete
A: 

Hi,

please put some code out here

Thanks

Narender