Как сделать пользовательский MKPolyline в SWIFT с дополнительным аргументом - цвет
Может ли кто-нибудь помочь мне с изготовлением на заказMKPolyline
с дополнительным аргументом Color?
CustomPolyline.swift
import Foundation
import MapKit
class CustomPolyline : MKPolyline {
let coordinates: UnsafeMutablePointer<CLLocationCoordinate2D>
let count : Int = 0
let color : String = "ff0000"
init(coordinates: UnsafeMutablePointer<CLLocationCoordinate2D>, count: Int, color: String) {
self.coordinates = coordinates
self.count = count
self.color = color
}
}
В этом
Polyline = CustomPolyline(coordinates: &Path, count: Path.count, color: "ff0000")
self.mapView.addOverlay(Polyline)
func mapView(mapView: MKMapView!, rendererForOverlay overlay: MKOverlay!) -> MKOverlayRenderer! {
if (overlay is CustomPolyline) {
var pr = MKPolylineRenderer(overlay: overlay);
pr.strokeColor = UIColor.colorWithRGBHex(0xff0000).colorWithAlphaComponent(0.5);
pr.lineWidth = 10;
return pr;
}
return nil
}
Мое решение не работает, и я не могу понять, почему. Полилинии вообще не видны. Я новичок в SWIFT, так что я думаю, что проблема с моимCustomPolyline
учебный класс. Спасибо за помощь.