小编Zac*_*ach的帖子

如何使用Swift更改MKAnnotation Color?

我已经MKAnnotations在地图上设置了,但我想改变不同场景的注释颜色.有没有办法改变注释的颜色?

以下是我的代码,如何实现颜色变化?

override func viewDidAppear(animated: Bool) {
    var annotationQuery = PFQuery(className: "Post")
    currentLoc = PFGeoPoint(location: MapViewLocationManager.location)
    //annotationQuery.whereKey("Location", nearGeoPoint: currentLoc, withinMiles: 10)
    annotationQuery.whereKeyExists("Location")
    annotationQuery.findObjectsInBackgroundWithBlock {
        (points, error) -> Void in
        if error == nil {
            // The find succeeded.
            println("Successful query for annotations")
            // Do something with the found objects

            let myPosts = points as! [PFObject]

            for post in myPosts {
                let point = post["Location"] as! PFGeoPoint
                let annotation = MKPointAnnotation()
                annotation.coordinate = CLLocationCoordinate2DMake(point.latitude, point.longitude)
                annotation.title = post["title"] as! …
Run Code Online (Sandbox Code Playgroud)

iphone xcode annotations ios swift

2
推荐指数
2
解决办法
1万
查看次数

标签 统计

annotations ×1

ios ×1

iphone ×1

swift ×1

xcode ×1