Próbuję dowiedzieć się, jak nakładać obraz na mapie IOS przy użyciu SWIFT. Stworzyłem następujący kod, który nakłada zielone kółko na mapie przy użyciu zestawu map. Chcę zastąpić zielone kółko prostokątnym obrazem tOver.png 500 500 Jestem nowym na rozwój iOS i szybkim. Do tej pory nie mogę znaleźć szybkiego przykładu lub dobrego zasobu.Jak nakładać obraz na mapie IOS za pomocą Swift
//
// ViewController.swift
// mapoverlaytest
//
import UIKit
import MapKit
class ViewController: UIViewController,MKMapViewDelegate {
@IBOutlet weak var mapView: MKMapView!
override func viewDidLoad() {
super.viewDidLoad()
self.mapView.delegate = self;
let location = CLLocationCoordinate2D(
latitude: 51.50007773,
longitude: -0.1246402
)
let span = MKCoordinateSpanMake(0.05, 0.05)
let region = MKCoordinateRegion(center: location, span: span)
mapView.setRegion(region, animated: true)
let annotation = MKPointAnnotation()
annotation.setCoordinate(location)
annotation.title = "Big Ben"
annotation.subtitle = "London"
var overlay = MKCircle (centerCoordinate: location, radius: 500)
mapView.addOverlay(overlay)
mapView.addAnnotation(annotation)
}
func mapView(
mapView: MKMapView!, rendererForOverlay
overlay: MKOverlay!) -> MKOverlayRenderer! {
if (overlay.isKindOfClass(MKCircle))
{
var circleRenderer = MKCircleRenderer(overlay: overlay)
circleRenderer.strokeColor = UIColor.greenColor()
circleRenderer.fillColor = UIColor(
red: 0,
green: 1.0,
blue: 0,
alpha: 0.5)
return circleRenderer
}
return nil
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}