相关疑难解决方法(0)

Swift的不同图像

我设法在Swift中获得了注释引脚的自定义图标,但现在我仍然使用2个不同的图像进行不同的注释.现在,按钮会向地图添加注释.应该有另一个按钮,它还添加了注释,但带有另一个图标.

有没有办法使用reuseId?

class ViewController: UIViewController, MKMapViewDelegate {

@IBOutlet weak var Map: MKMapView!

@IBAction func btpressed(sender: AnyObject) {

    var lat:CLLocationDegrees = 40.748708
    var long:CLLocationDegrees = -73.985643
    var latDelta:CLLocationDegrees = 0.01
    var longDelta:CLLocationDegrees = 0.01

    var span:MKCoordinateSpan = MKCoordinateSpanMake(latDelta, longDelta)
    var location:CLLocationCoordinate2D = CLLocationCoordinate2DMake(lat, long)
    var region:MKCoordinateRegion = MKCoordinateRegionMake(location, span)

    Map.setRegion(region, animated: true)


    var information = MKPointAnnotation()
    information.coordinate = location
    information.title = "Test Title!"
    information.subtitle = "Subtitle"

    Map.addAnnotation(information)
}

func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
    if !(annotation is MKPointAnnotation) …
Run Code Online (Sandbox Code Playgroud)

mkmapview mkannotationview ios mkpointannotation swift

30
推荐指数
2
解决办法
5万
查看次数