【发布时间】:2021-06-04 22:35:37
【问题描述】:
我在地图上使用了自定义按钮,但现在我意识到我想使用普通图钉,例如 MapPin。如何更改我的代码以适应 MapPin 的使用,以便当我点击它时,会发生相同的操作。
Map(coordinateRegion: $region, annotationItems: getAnnotated()) { item in
MapAnnotation(coordinate: item.coordinate) {
Button(action: {
selected.item = item // <--- here
showSheet.toggle()
}){
Image("icon")
.resizable()
.frame(width: 70, height: 70)
.foregroundColor(.white)
.cornerRadius(9.0)
}
.background(Circle())
.foregroundColor(Color.green)
}
}
我尝试将Image() 换成MapPin() 作为最后的努力,但没有奏效。
【问题讨论】:
标签: swiftui swiftui-navigationlink