1
내 클래스하려면 tintColor하는 기능을 가지고tintColor - 임의의 색상, 이유는 무엇입니까?
func pinColor() -> UIColor {
switch status.text! {
case "online":
return UIColor(red: 46/255, green: 204/255, blue: 113/255, alpha: 1.0)
default:
return UIColor.red
}
}
또한
I이 확장 가지고
extension ViewController: MKMapViewDelegate {
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
if let annotation = annotation as? Marker {
let identifier = "pin"
var view: MKPinAnnotationView
if let dequeuedView = map.dequeueReusableAnnotationView(withIdentifier: identifier)
as? MKPinAnnotationView {
dequeuedView.annotation = annotation
view = dequeuedView
} else {
view = MKPinAnnotationView(annotation: annotation, reuseIdentifier: identifier)
view.canShowCallout = true
view.calloutOffset = CGPoint(x: -5, y: 5)
view.rightCalloutAccessoryView = UIButton(type: .detailDisclosure) as UIView
view.pinTintColor = annotation.pinColor()
}
return view
}
return nil
}
}
I는지도보기 매 10 초 어레이 내 데이터를 로딩하고이처럼 선물 :
func mapView() {
map.layoutMargins = UIEdgeInsets(top: 30, left: 30, bottom: 30, right: 30)
map.showAnnotations(markersArrayFiltered!, animated: true)
}
오류 : - 내가 새로운 데이터를로드 할 때마다, 핀의 내 색깔은 다르지만 내 나타나서 a는 변하지 않는다.
내가 무슨 일을 했는가?
고마워요! 이제 모든 것이 제대로 작동합니다. 이제 mapKit에 대해 더 알고 있습니다 =) –