0
我想創建一個使用MapKit的應用程序,我想在地圖上創建註釋,但我很努力地將圖像放在地圖註釋上。將圖像添加到地圖註釋(Swift)
我與編程斯威夫特一個初學者,我已經工作過this tutorial,但我找不到任何地方上網,可以幫助你實現圖像,大多數導遊使用目的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
}
}
請參閱http://stackoverflow.com/questions/25631410/swift-different-images-for-annotation,http://stackoverflow.com/questions/24467408/swift-add-mkannotationview-to-mkmapview。 – Anna