0

我想用边框画线,

现在我正在做同样的事情两次,这意味着我首先用笔画 +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);  
            }

谢谢。

4

0 回答 0