1

can anyone give me simple code to create a line in iphone using drawrect?

Jayaraj
  • 89
  • 2
  • 6

1 Answers1

0

Go through the blog tutorial for drawing shape including line

http://howtomakeiphoneapps.com/2009/08/how-to-draw-shapes-with-core-graphics/

Edited: Below is the code for drawing line

- (void)drawRect:(CGRect)rect {
    CGContextRef c = UIGraphicsGetCurrentContext();

    CGFloat red[4] = {1.0f, 0.0f, 0.0f, 1.0f};
    CGContextSetStrokeColor(c, red);
    CGContextBeginPath(c);
    CGContextMoveToPoint(c, 5.0f, 5.0f);
    CGContextAddLineToPoint(c, 50.0f, 50.0f);
    CGContextStrokePath(c);
}
Jhaliya - Praveen Sharma
  • 31,697
  • 9
  • 72
  • 76