MKMapView自定义UserLocation注解
我希望自定义 MKMapView userLocation 注释,以像官方地图应用程序一样绘制标题箭头。
我正在尝试在 viewForAnnotation: 中执行此操作,
- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[MKUserLocation class]]) {
}
}
但我无法找到下一步要做什么来获取 UserLocation 的视图并对其进行自定义。
非常感谢...
I am looking to customize the MKMapView userLocation annotation, to draw a heading arrow like the official map app.
I am trying to do this in viewForAnnotation:
- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[MKUserLocation class]]) {
}
}
but I am unable to find what to do next to get the view for UserLocation and customize it.
Many thanks...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我创建了 SVPulsingAnnotationView,它是
MKUserLocationView
的可自定义副本。您可以像任何其他
MKAnnotationView
一样实例化它:I created SVPulsingAnnotationView, a customizable replica of
MKUserLocationView
.You instantiate it just like any other
MKAnnotationView
:默认用户位置标记的类(至少在 SDK 4.2 中)是 MKUserLocationView,但它不是公开的,因此您无法创建实例进行修改,否则会面临被应用商店拒绝的风险。您必须创建自己的 MKAnnotationView (或 MKAnnotationView 的子类)。
The class for the default user location marker (at least in SDK 4.2) is MKUserLocationView, but this is not public so you cannot create an instance to modify without risking rejection from the app store. You'll have to create your own MKAnnotationView (or subclass of MKAnnotationView) instead.
导入 UIKit
导入地图工具包
import CoreLocation
class secondaryViewController: UIViewController, CLLocationManagerDelegate,MKMapViewDelegate{
// var locationmanager = CLLocationManager()
/* public func locationManager(_ manager: CLLocationManager, didUpdateLocationslocations: [CLLocation]) {
import UIKit
import MapKit
import CoreLocation
class secondViewController: UIViewController, CLLocationManagerDelegate,MKMapViewDelegate{
// var locationmanager = CLLocationManager()
/* public func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {