tags:

views:

247

answers:

2

i want to draw line between two points in my view how it possible.?

Edit:ya thax.i have got solution. Line draw perfectly.I want to draw multiple line with different points.I am using for loop and every rotaion i pass the start and end points.but only last point is drawn.how to solve this problem?

+3  A: 

The QuartzDemo application has great examples of how to use CoreGraphics, including lines and bezier curves. download here

Take a look at QuartzLineDrawing.m in the sample code. You'll be able to find some great examples there :-)

Kyle Kinkade
+1  A: 

You need to use a few CoreGraphics functions:

// get the current context
CGContextRef context = UIGraphicsGetCurrentContext();

// set the stroke color and width
CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 1.0);
CGContextSetLineWidth(context, 2.0);

// move to your first point
CGContextMoveToPoint(context, 10.0, 10.0);

// add a line to your second point
CGContextAddLineToPoint(context, 50.0, 10.0);

// tell the context to draw the stroked line
CGContextStrokePath(context);

This example would draw a horizontal white line with a thickness of 2. Apple has some great sample code and tutorials including the QuartzDemo tutorial: http://developer.apple.com/iPhone/library/samplecode/QuartzDemo/index.html.

richleland