Я не знаю, как изменить код цвета булавки в iOS 9 (потому что в последнее время Apple изменил код для него), и я все еще новичок в Swift. Итак, я не знаю, как интегрировать pinTintColor
в мой код.Изменить цветной контакт iOS 9 Mapkit
Вы найдете ниже мой код:
import UIKit
import MapKit
class ViewController: UIViewController, MKMapViewDelegate {
@IBOutlet var map: MKMapView!
override func viewDidLoad() {
super.viewDidLoad()
let annotation = MKPointAnnotation()
let latitude:CLLocationDegrees = 40.5
let longitude:CLLocationDegrees = -74.6
let latDelta:CLLocationDegrees = 150
let lonDelta:CLLocationDegrees = 150
let span:MKCoordinateSpan = MKCoordinateSpanMake(latDelta, lonDelta)
let location:CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude, longitude)
let region:MKCoordinateRegion = MKCoordinateRegionMake(location, span)
map.setRegion(region, animated: false)
annotation.coordinate = location
annotation.title = "Niagara Falls"
annotation.subtitle = "One day bla bla"
map.addAnnotation(annotation)
}
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
// simple and inefficient example
let annotationView = MKPinAnnotationView()
annotationView.pinColor = .Purple
return annotationView
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Если приложение по-прежнему нуждается в поддержке iOS 8, это изменение не должно выполняться. – rmaddy
@rmaddy Но он задает вопрос с точки зрения iOS 9 - _ «Я не знаю, как изменить код для цвета булавки в iOS 9» _. – Unheilig
OP может быть немного запутан здесь и не осознавать, что они, вероятно, должны поддерживать iOS 8, что означает, что изменить ничего не стоит. Я просто указываю на возможность, на всякий случай. – rmaddy