Fügen Sie mit MapKit in swift 2.1 eine andere Stiftfarbe hinzu

Ich bin neu in Swift. Ich versuche, einen anderen Farbstift oder einen benutzerdefinierten Stift auf einem bestimmten Stift zu haben. Mein Code funktioniert. Ich habe eine lila Nadel, aber ich möchte einen Unterschied zwischen ihnen machen. Wie kann ich es tun? Ich denke, es gibt etwas zu tun in MapView Delegate-Methode, aber ich habe es nicht gefunden.

import UIKit
import MapKit

class MapsViewController: UIViewController , MKMapViewDelegate{
    var shops: NSArray? {
        didSet{
            self.loadMaps()
        }
    }

    @IBOutlet weak var map: MKMapView?

    override func viewDidLoad() {
        super.viewDidLoad()
        loadMaps()
        self.title = "Carte"
        self.map!.delegate = self

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
        // simple and inefficient example

        let annotationView = MKPinAnnotationView()

        annotationView.pinTintColor = UIColor.purpleColor()
        return annotationView
    }

    func loadMaps(){
//        navigationController?.navigationBar.topItem!.title = "Carte"
        let shopsArray = self.shops! as NSArray
        for shop in shopsArray  {

            let location = CLLocationCoordinate2D(
                latitude: shop["lat"] as! Double,
                longitude: shop["long"] as! Double
            )


            let annotation = MKPointAnnotation()
            annotation.coordinate   = location
            annotation.title        = shop["name"] as? String
            annotation.subtitle     = shop["addresse"] as? String

            map?.addAnnotation(annotation)

        }





        // add point



    }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}

Antworten auf die Frage(2)

Ihre Antwort auf die Frage