0
私はmapkitに2つのピンを持っています、両方とも同じ注釈ビューの下にありますので、両方のピンが同じ色です。どのようにピンを異なる色にすることができますか?私はこんにちはが赤で、こんにちはは青くなりたいです。同じannotationview(swift3)の下でmapkitのピンの色を変更する方法
import UIKit
import MapKit
class ViewController: UIViewController, MKMapViewDelegate {
@IBOutlet var jmap: MKMapView!
override func viewDidLoad() {
jmap.delegate = self;
let hello = MKPointAnnotation()
hello.coordinate = CLLocationCoordinate2D(latitude: 40, longitude: -73)
jmap.addAnnotation(hello)
let hellox = MKPointAnnotation()
hellox.coordinate = CLLocationCoordinate2D(latitude: 34, longitude: -72)
jmap.addAnnotation(hellox)
}
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
let annotationView = MKPinAnnotationView()
annotationView.pinTintColor = .blue
return annotationView
}}