ios - Adapting PinTintColor to Ray Wenderlich tutorial for mapkit -


i'm using tutorial building first app. http://www.raywenderlich.com/90971/introduction-mapkit-swift-tutorial

ive searched pintintcolor nothing comes up.

basically tutorial uses code set color

// pincolor disciplines: sculpture, plaque, mural, monument, other func pincolor() -> mkpinannotationcolor{     switch discipline {     case "sculpture", "plaque":         return .red     case "mural", "monument":         return .purple     default:         return .green 

the trouble apple has on developers site

https://developer.apple.com/library/mac/releasenotes/general/apidiffsmacosx10_11/swift/mapkit.html

modified mkpinannotationview declaration

from:

class mkpinannotationview : mkannotationview {     var pincolor: mkpinannotationcolor     var animatesdrop: bool } 

to:

class mkpinannotationview : mkannotationview {     class func redpincolor() -> nscolor     class func greenpincolor() -> nscolor     class func purplepincolor() -> nscolor     var pintintcolor: nscolor!     var animatesdrop: bool     var pincolor: mkpinannotationcolor } 

the ray wenderlich tutorial setup fair bit different don't quite understand how set same way it. have tried few different configurations can't work.

any appreciated

cheers

instead of use property pincolor (deprecated), use property pintintcolor (ios9)

//view.pincolor = mkpinannotationcolor.green  view.pintintcolor = uicolor.greencolor()  //uicolor functions public class func blackcolor() -> uicolor // 0.0 white  public class func darkgraycolor() -> uicolor // 0.333 white  public class func lightgraycolor() -> uicolor // 0.667 white  public class func whitecolor() -> uicolor // 1.0 white  public class func graycolor() -> uicolor // 0.5 white  public class func redcolor() -> uicolor // 1.0, 0.0, 0.0 rgb  public class func greencolor() -> uicolor // 0.0, 1.0, 0.0 rgb  public class func bluecolor() -> uicolor // 0.0, 0.0, 1.0 rgb  public class func cyancolor() -> uicolor // 0.0, 1.0, 1.0 rgb  public class func yellowcolor() -> uicolor // 1.0, 1.0, 0.0 rgb  public class func magentacolor() -> uicolor // 1.0, 0.0, 1.0 rgb  public class func orangecolor() -> uicolor // 1.0, 0.5, 0.0 rgb  public class func purplecolor() -> uicolor // 0.5, 0.0, 0.5 rgb  public class func browncolor() -> uicolor // 0.6, 0.4, 0.2 rgb  public class func clearcolor() -> uicolor // 0.0 white, 0.0 alpha  

here full picture:

import mapkit  class myannotation: mkannotation, nsobject  {     let identifier: string     let title: string?     let subtitle: string?     let coordinate: cllocationcoordinate2d      init(identifier: string, title: string, subtitle: string, coordinate: cllocationcoordinate2d)     {         self.identifier = identifier         self.title = title         self.subtitle = subtitle         self.coordinate = coordinate          super.init()     }      func mapitem() -> mkmapitem     {         let addressdictionary = [string(cnpostaladdressstreetkey): self.subtitle!]         let placemark = mkplacemark(coordinate: self.coordinate, addressdictionary: addressdictionary)          let mapitem = mkmapitem(placemark: placemark)         mapitem.name = self.title          return mapitem     } }   func mapview(mapview: mkmapview, viewforannotation annotation: mkannotation) -> mkannotationview? {     if let annotation = annotation as? myannotation     {         let identifier = annotation.identifier         var view = mkpinannotationview()          if let dequeuedview = mapview.dequeuereusableannotationviewwithidentifier(identifier) as! mkpinannotationview!         {             view = dequeuedview             view.annotation = annotation         }         else         {             view = mkpinannotationview(annotation: annotation, reuseidentifier: identifier)             view.animatesdrop = true             view.canshowcallout = true              switch identifier              {                 case "sculpture", "plaque":                     view.pintintcolor = uicolor.redcolor()                 case "mural", "monument":                     view.pintintcolor = uicolor.purplecolor()                 default:                     view.pintintcolor = uicolor.greencolor()             }         }         return view     }     return nil } 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -