Circle around a point on an MKMapView
I need to d开发者_Python百科raw a circle with a specified radius around an arbitrary point (not necessarily the user's location) on an MKMapView. I would like the appearance to be similar to the circle that the Maps app uses, to show the accuracy of the user's location.
Is there a recommended way of doing this, or will I need to create a custom overlay?
You might want to look at MKCircle and MKCircleView, which are part of the MapKit API and are designed for drawing circles on an MKMapView. I don't think there's an easy way to duplicate the animated "zeroing in" effect like the user location circle does, but you should be able to use these classes to show a fixed degree of accuracy around a given coordinate.
You could use MKAnnoations, if you want to tie it to a map location, but you'll still need to provide the view (viewForAnnotation, or something similar -- see docs) to draw the circle.
If you need to know how to draw the circle, that's CGContextStrokeEllipseInRect() for the outline and CGContextFillElipseInRect() for the other part. If you put all that into a view, you can use UIView animations to make it "throb", like the blue map dot.
If you have more specific questions, you'll have to ask them -- the one was kind of open-ended.
精彩评论