2012-04-04 3 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) { 
    ... 
}