Tôi đang cố vẽ đường thẳng giữa hai điểm trong chế độ xem lớp phủ. Trong phương pháp MKOverlayView, tôi nghĩ rằng tôi đang làm đúng nhưng tôi không hiểu tại sao nó không vẽ bất kỳ ...dòng không được vẽ trên chế độ xem lớp phủ
Có ai biết tại sao không?
- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale
inContext:(CGContextRef)context
{
UIGraphicsPushContext(context);
MKMapRect theMapRect = [[self overlay] boundingMapRect];
CGRect theRect = [self rectForMapRect:theMapRect];
// Clip the context to the bounding rectangle.
CGContextAddRect(context, theRect);
CGContextClip(context);
CGPoint startP = {theMapRect.origin.x, theMapRect.origin.y};
CGPoint endP = {theMapRect.origin.x + theMapRect.size.width,
theMapRect.origin.y + theMapRect.size.height};
CGContextSetLineWidth(context, 3.0);
CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);
CGContextBeginPath(context);
CGContextMoveToPoint(context, startP.x, startP.y);
CGContextAddLineToPoint(context, endP.x, endP.y);
CGContextStrokePath(context);
UIGraphicsPopContext();
}
Cảm ơn sự giúp đỡ của bạn.
Đã hoạt động !! Cảm ơn nhiều!!! –
Xin chào, tôi có thêm một câu hỏi nữa ... Nếu tôi khởi tạo CGPoint từ boundingMapRect, tôi nên làm gì ???? –
oh .. và lý do tôi không sử dụng MkPolylineView là tôi cần phải vẽ một mũi tên không chỉ đường thẳng .... –