2012-04-04 16 views
-1

15本の水平線を描画し、それらの間に20ポイントのスペースを描きたい。私はなぜこのコードが動作しないのか理解できません。複数の線を描くQuartz 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); 

    } 

} 

ありがとうございます!

+2

ネヴァーマインド。私はアホです。私はforループを間違って書いた。 – Cosmin

答えて

1

はい、forループのようになります。

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