[英]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.