Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 绘制多条线_Iphone_Draw_Quartz 2d_Lines - Fatal编程技术网

Iphone 绘制多条线

Iphone 绘制多条线,iphone,draw,quartz-2d,lines,Iphone,Draw,Quartz 2d,Lines,我想画15条水平线,它们之间有20点的间隔。我不明白为什么这个代码不起作用 - (void)drawRect:(CGRect)rect { // Drawing code CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor); CGContextSetLineWidth(context

我想画15条水平线,它们之间有20点的间隔。我不明白为什么这个代码不起作用

 - (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);

   }

}
-(void)drawRect:(CGRect)rect
{
//绘图代码
CGContextRef context=UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(上下文[UIColor redColor].CGColor);
CGContextSetLineWidth(上下文,2.0);

对于(int i=20;i+=20;iYes),for循环应为:

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

for(inti=20;iNevermind)。我是个白痴。我把for循环写错了。