Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.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_Ios4 - Fatal编程技术网

Iphone 如何使用渐变效果颜色绘制路线

Iphone 如何使用渐变效果颜色绘制路线,iphone,ios,ios4,Iphone,Ios,Ios4,我有代码在uimapview中用特定颜色绘制路线。但我需要一个梯度效果,让这条线淹没。谁能帮我解决这个问题?我现在的代码放在这里供参考 CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); routeView=(UIImageView*)[routeDict objectForKey:[placemarkarray objectAtIndex:2]]; lineColor=(UIColor *)[colors objectAtIn

我有代码在uimapview中用特定颜色绘制路线。但我需要一个梯度效果,让这条线淹没。谁能帮我解决这个问题?我现在的代码放在这里供参考

CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
routeView=(UIImageView*)[routeDict objectForKey:[placemarkarray objectAtIndex:2]];
lineColor=(UIColor *)[colors objectAtIndex:routeView.tag];
CGContextRef context =  CGBitmapContextCreate(nil,
                                              routeView.frame.size.width,
                                              routeView.frame.size.height,
                                              8,
                                              4 * routeView.frame.size.width,
                                              colorSpace,
                                              kCGImageAlphaPremultipliedLast);






CGColorSpaceRelease(colorSpace);
CGContextSetStrokeColorWithColor(context, lineColor.CGColor);
CGContextSetRGBFillColor(context, 0.0, 0.0, 1.0, 1.0);
CGContextSetLineWidth(context, 3.0);



for(int i = 0; i < routes.count; i++) {
    CLLocation* location = [routes objectAtIndex:i];
    CGPoint point = [mapView convertCoordinate:location.coordinate toPointToView:routeView];

    if(i == 0) {
        CGContextMoveToPoint(context, point.x, routeView.frame.size.height - point.y);
    } else {
        CGContextAddLineToPoint(context, point.x, routeView.frame.size.height - point.y);
    }
}


CGContextStrokePath(context);



CGImageRef image = CGBitmapContextCreateImage(context);
CGContextRelease(context);
UIImage* img = [UIImage imageWithCGImage:image];
CGImageRelease(image);

routeView.image = img;
CGColorSpaceRef colorSpace=CGColorSpaceCreateDeviceRGB();
routeView=(UIImageView*)[routeDict objectForKey:[placemarkarray objectAtIndex:2]];
lineColor=(UIColor*)[colors对象索引:routeView.tag];
CGContextRef context=CGBitmapContextCreate(无,
routeView.frame.size.width,
routeView.frame.size.height,
8.
4*routeView.frame.size.width,
色彩空间,
KCGIMAGEAlphaPremultipledLast);
CGCOLORSPACTERELEASE(色彩空间);
CGContextSetStrokeColorWithColor(上下文,lineColor.CGColor);
CGContextSetRGBFillColor(上下文,0.0,0.0,1.0,1.0);
CGContextSetLineWidth(上下文,3.0);
对于(int i=0;i

这里包含我的latitude logitude数组的路由,我之前初始化的线颜色。routeView是包含创建的图像的最终图像视图。

@Rushabh:那一个不适合我。很抱歉