2012-04-04 10 views
-1

Ich möchte 15 horizontale Linien zeichnen, mit 20 Punkten Abstand zwischen ihnen. Ich kann nicht verstehen, warum dieser Code nicht funktioniert.Zeichnen Sie mehrere Linien Quarz 2D

- (void)drawRect:(CGRect)rect 
{ 
    // Drawing code 
    CGContextRef context = UIGraphicsGetCurrentContext(); 
    CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor); 
    CGContextSetLineWidth(context, 2.0); 
    for (int i=20;i+=20;i<=20*15) { 
     CGContextBeginPath(context); 
     CGContextMoveToPoint(context, 10, i); 
     CGContextAddLineToPoint(context, 310, i); 
     CGContextStrokePath(context); 

    } 

} 

Vielen Dank!

+2

Nevermind. Ich bin ein Idiot. Ich habe die for-Schleife falsch geschrieben. – Cosmin

Antwort

1

Ja, sollte die for-Schleife sein:

for (int i=20; i<=20*15; i+=20) { 
    ... 
} 
Verwandte Themen