Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.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_Ios - Fatal编程技术网

Iphone 画线时的动画

Iphone 画线时的动画,iphone,ios,Iphone,Ios,我正在使用下面的函数在两个坐标之间画一条线,现在我想显示旋转动画,就像线在一个接一个的点上画一样,那么我该怎么做呢 x1 = [[xCoordinates objectAtIndex:i]intValue]; y1 = [[yCoordinates objectAtIndex:i]intValue]; x2 = [[xCoordinates objectAtIndex:i+1]intValue]; y2

我正在使用下面的函数在两个坐标之间画一条线,现在我想显示旋转动画,就像线在一个接一个的点上画一样,那么我该怎么做呢

            x1 = [[xCoordinates objectAtIndex:i]intValue];
            y1 = [[yCoordinates objectAtIndex:i]intValue];

           x2 = [[xCoordinates objectAtIndex:i+1]intValue];
           y2 = [[yCoordinates objectAtIndex:i+1]intValue];
            UIImageView *drawImage = [[UIImageView alloc] init];
            drawImage.frame = self.view.frame;
            [self.view addSubview:drawImage];

            UIGraphicsBeginImageContext(self.view.frame.size);
            [drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
            CGContextRef context = UIGraphicsGetCurrentContext();
            CGContextSetLineCap(context, kCGLineCapRound);
            CGContextSetLineWidth(context, 5.0);
            CGContextSetRGBStrokeColor(context, 0.5, 1.0, 1.0, 1.0); 
            CGContextMoveToPoint(context, xBegin, yBegin);
            CGContextAddLineToPoint(context, x1, y1);
            CGContextStrokePath(context);
            drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
            UIGraphicsEndImageContext();
            [drawImage release];
            [UIView commitAnimations];

下面是一个示例代码,可以帮助您实现所需的
http://nachbaur.com/blog/core-animation-part-4

这是一个很好的代码,但对我没有帮助bcz我希望动画是逐像素的,当线条在两点之间绘制时,有很多算法可以得到原点和终点之间的点。我以为你知道那件事。这就是为什么我只提供了动画代码。