问题描述
我只是尝试触摸地图注释,但是按钮的操作不起作用。 我试图弄清楚如何解决它,但是到目前为止没有。我想使用不带UIKit桥的Map。
这是我的地图:
Map(coordinateRegion: $locationManager.currentLocation,interactionModes: .all,showsUserLocation: true,userTrackingMode: $trackingMode,annotationItems: $locationManager.annotations.wrappedValue) { location in
MapAnnotation(coordinate: location.coordinate,anchorPoint: CGPoint(x: 0.5,y: 0.5)) {
MapAnnotationView(name: location.title,image: Image("dog"))
}
}
这是我的MapAnnotationView:
import SwiftUI
struct MapAnnotationView: View {
var name: String
var image: Image
@State var size: CGFloat = 20
var body: some View {
vstack {
Button(action: {
size = $size.wrappedValue == 20 ? 60 : 20
print("TAPPED =====>")
},label: {
image
.resizable(capInsets: EdgeInsets(),resizingMode: .stretch)
.frame(width: $size.wrappedValue,height: $size.wrappedValue,alignment: .center)
.clipShape(Circle())
.overlay(Circle().stroke(Color.white,linewidth: 2))
Text(name)
.font(.caption)
.fontWeight(.semibold)
.foregroundColor(.primary)
})
}
.shadow(radius: 5)
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)