gpt4 book ai didi

ios - 将 PinTintColor 调整为 mapkit 的 Ray Wenderlich 教程

转载 作者:搜寻专家 更新时间:2023-10-30 22:09:45 24 4
gpt4 key购买 nike

我正在使用教程来构建我的第一个应用程序。 http://www.raywenderlich.com/90971/introduction-mapkit-swift-tutorial

我搜索了 pintintcolor 但没有搜索到。

基本上教程使用这段代码来设置颜色

// pinColor for disciplines: Sculpture, Plaque, Mural, Monument, other
func pinColor() -> MKPinAnnotationColor{
switch discipline {
case "Sculpture", "Plaque":
return .Red
case "Mural", "Monument":
return .Purple
default:
return .Green

问题是苹果在开发者网站上有什么

https://developer.apple.com/library/mac/releasenotes/General/APIDiffsMacOSX10_11/Swift/MapKit.html

修改后的 MKPinAnnotationView声明

来自:

class MKPinAnnotationView : MKAnnotationView {
var pinColor: MKPinAnnotationColor
var animatesDrop: Bool
}

收件人:

class MKPinAnnotationView : MKAnnotationView {
class func redPinColor() -> NSColor
class func greenPinColor() -> NSColor
class func purplePinColor() -> NSColor
var pinTintColor: NSColor!
var animatesDrop: Bool
var pinColor: MKPinAnnotationColor
}

Ray Wenderlich 教程的设置有点不同,所以我不太了解如何按照相同的方式进行设置。我尝试了几种不同的配置,但无法正常工作。

感谢任何帮助

干杯

最佳答案

万一其他人正在学习教程并看到以下错误:“‘MKPinAnnotationColor’在 iOS 9.0 中已弃用:改用 MKPinAnnotationView 的 pinTintColor”

只需更新 pinColor 例程以返回 UIColor。

func pinColor() -> UIColor  {
switch discipline {
case "Sculpture", "Plaque":
return UIColor.redColor()
case "Mural", "Monument":
return UIColor.purpleColor()
default:
return UIColor.greenColor()
}
}

然后进行相应的调用以像这样设置 pinTintColor:

  view.pinTintColor = annotation.pinColor()

关于ios - 将 PinTintColor 调整为 mapkit 的 Ray Wenderlich 教程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32692805/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com