MKCircleView和lineDashPattern

时间:2012-11-08 23:20:02

标签: iphone ios

我想为MKCircleView创建一个lineDashPattern,它显示四个大小相等的段,中间有间隙。我认为我遇到的问题是对于MKCircleView,lineDashPattern不使用地图点;它也不是使用像素。或者我的数学错了。我开始使用这个叠加层:

double radius = 100.0;
double mradius = radius * MKMapPointsPerMeterAtLatitude(coordinate.latitude);
double circumference = mradius * M_PI * 2.0;
double segment = circumference / 4.0;
double line = segment * 0.85;
double gap = segment - line;
MKCircle *circle = [MKCircle circleWithMapRect:[self boundingMapRect]];
self.overlayView = [[MKCircleView alloc] initWithCircle:circle];
overlayView.strokeColor = [UIColor blueColor];
overlayView.lineWidth = 5;
overlayView.lineDashPattern = @[[NSNumber numberWithDouble:line], [NSNumber numberWithDouble:gap]];

这会产生不会给我留下任何空隙的大数字,但是基于这个空间并没有帮助,尽管它会产生更小,更可信的数字:

CGPoint point = [overlayView convertPoint:[mapView convertCoordinate:coordinate toPointToView:mapView] fromView:mapView];
double circumference = point.x * M_PI * 2.0;

有什么想法吗?

0 个答案:

没有答案