【发布时间】:2015-05-12 15:26:13
【问题描述】:
我正在尝试创建一个使用 MapKit 的应用程序,并且我想在地图上创建注释,但我正在努力将图像放在地图注释上。
我是 Swift 编程的初学者,我一直在工作 this tutorial,但是我在网上找不到任何可以帮助您实现图像的地方,大多数指南都使用 Objective C。
这是我的注释类,在我的视图控制器中调用。
注意:我有我的小图像,我想在 images.xcassets 文件夹中显示为“mapAnnotation”
let buildingName = location(title: "Building Name",
locationName: "Location",
coordinate: CLLocationCoordinate2D(latitude: NUMBER, longitude: NUMBER))
theMapview.addAnnotation(buildingName)
这里是注解类...
class location: NSObject, MKAnnotation {
let title: String
let locationName: String
let coordinate: CLLocationCoordinate2D
//Retrieve an image
var image = UIImage(named: "mapAnnotation")
init(title: String, locationName:String, coordinate: CLLocationCoordinate2D) {
self.title = title
self.locationName = locationName
self.coordinate = coordinate
self.image
super.init()
}
var subtitle: String {
return locationName
}
}
【问题讨论】:
标签: ios swift dictionary annotations callout