【发布时间】:2017-01-21 22:33:18
【问题描述】:
下面是我列出 1 个注释引脚的代码。现在是红色的。我怎样才能让它变成蓝色?我需要放入扩展文件吗?该代码还包括当前用户的位置。我也可以将注释设为按钮吗?
import UIKit
import MapKit
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate {
@IBOutlet var map: MKMapView!
let manager = CLLocationManager()
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let location = locations[0]
let span: MKCoordinateSpan = MKCoordinateSpanMake(1.0, 1.0)
let myLocation:CLLocationCoordinate2D = CLLocationCoordinate2DMake(location.coordinate.latitude, location.coordinate.longitude)
let region:MKCoordinateRegion = MKCoordinateRegionMake(myLocation, span)
map.setRegion(region, animated: true)
print(location.altitude)
print(location.speed)
self.map.showsUserLocation = true
}
override func viewDidLoad() {
super.viewDidLoad()
manager.delegate = self
manager.desiredAccuracy = kCLLocationAccuracyBest
manager.requestWhenInUseAuthorization()
manager.startUpdatingLocation()
let location:CLLocationCoordinate2D = CLLocationCoordinate2DMake(37.5656, -122.443)
let annoation = MKPointAnnotation()
annoation.coordinate = location
annoation.title = "MYSHOP"
annoation.subtitle = "Come Visit"
map.addAnnotation(annoation)
}
}
【问题讨论】:
标签: ios swift annotations swift3 mapkit