![](/img/trans.png)
[英]ios swift 4 Google Maps - How do I remove the fade in/fade out animation on a GMS Marker while dragging?
[英]How to remove google map marker with fade out animation iOS swift 3?
我正在尝试使用淡出动画来删除我的Google地图标记。 我尝试过
CATransaction.begin()
CATransaction.setAnimationDuration(1.0)
myMarker.marker?.map = nil
CATransaction.commit()
CATransaction
适用于myMarker.marker?.rotation
CATransaction
,但不适用于淡出动画。 我现在应该怎么办?
尝试用动画将其隐藏起来,在option参数中使用您选择的任何方法:
UIView.animate(withDuration: 0.5, delay: 0.0, options: .curveEaseOut, animations: {
self.myMarker.opacity = 0.0
}, completion: { (true) in
self.myMarker.map = nil
})
如果有多个标记或依赖于该标记的某些代码片段,并且您需要同步删除它们,则应在后台线程中完成该过程。 但是后台线程无法更新UI。
因此,您需要在主线程中执行UI更新部分。 就像我在这里所做的一样
//Swift 3.1
DispatchQueue.global(qos: .background).async {
//HERE MAY HAVE SOME DEPENDENT CODE
DispatchQueue.main.async {
UIView.animate(withDuration: 0.5, animations: {
self.myMarker.marker?.opacity = 0.0
}, completion: { (yes) in
self.myMarker.marker?.map = nil
})
}
//HERE MAY HAVE SOME DEPENDENT CODE
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.