我想绘制带边框的线条,
现在我做两次相同的事情,意味着首先我用笔划+3绘制线条并再次绘制正常笔划的线条,如1,
所以我为它做了两次循环,
还有其他方法可以提高性能吗?或任何相似的方式同时画两条线。??
我的代码是
if (locations && ([locations length]/16 > 1)) {
CGPoint point;
polylinewidth=10;
CGContextSetLineWidth(context, polylinewidth);
CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);
for (int i = 0; i <= locations.length - 32; i += 32) {
NSAutoreleasePool *loc = [[NSAutoreleasePool alloc]init];
CLLocationCoordinate2D coordinates;
coordinates.latitude = hexDecode_iPhone([locations substringWithRange:NSMakeRange(i, 16)]);
coordinates.longitude = hexDecode_iPhone([locations substringWithRange:NSMakeRange(i+16, 16)]);
point = [mapView convertCoordinate:coordinates toPointToView:self.mapView];
if (i == 0)
CGContextMoveToPoint(context, point.x, point.y);
else
CGContextAddLineToPoint(context, point.x, point.y);
[loc drain];
}
CGContextStrokePath(context);
CGContextSetLineWidth(context, polylinewidth-5);
CGContextSetAlpha(context, 0.6);
CGContextSetStrokeColorWithColor(context, color.CGColor);
for (int i = 0; i <= locations.length - 32; i += 32) {
NSAutoreleasePool *loc = [[NSAutoreleasePool alloc]init];
CLLocationCoordinate2D coordinates;
coordinates.latitude = hexDecode_iPhone([locations substringWithRange:NSMakeRange(i, 16)]);
coordinates.longitude = hexDecode_iPhone([locations substringWithRange:NSMakeRange(i+16, 16)]);
point = [mapView convertCoordinate:coordinates toPointToView:self.mapView];
if (i == 0)
CGContextMoveToPoint(context, point.x, point.y);
else
CGContextAddLineToPoint(context, point.x, point.y);
[loc drain];
}
CGContextStrokePath(context);
}
感谢。